home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / othergnu / indent~1.zoo / texinfo.tex < prev    next >
Encoding:
Text File  |  1992-08-06  |  108.7 KB  |  3,408 lines

  1. %% TeX macros to handle texinfo files
  2.  
  3. %   Copyright (C) 1985, 86, 88, 90, 91, 92 Free Software Foundation, Inc.
  4.  
  5. %This texinfo.tex file is free software; you can redistribute it and/or
  6. %modify it under the terms of the GNU General Public License as
  7. %published by the Free Software Foundation; either version 2, or (at
  8. %your option) any later version.
  9.  
  10. %This texinfo.tex file is distributed in the hope that it will be
  11. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  12. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. %General Public License for more details.
  14.  
  15. %You should have received a copy of the GNU General Public License
  16. %along with this texinfo.tex file; see the file COPYING.  If not, write
  17. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18. %USA.
  19.  
  20.  
  21. %In other words, you are welcome to use, share and improve this program.
  22. %You are forbidden to forbid anyone else to use, share and improve
  23. %what you give them.   Help stamp out software-hoarding!
  24.  
  25. \def\texinfoversion{2.75}
  26. \message{Loading texinfo package [Version \texinfoversion]:}
  27. \message{}
  28.  
  29. % Print the version number if in a .fmt file.
  30. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  31.  
  32. % Save some parts of plain tex whose names we will redefine.
  33.  
  34. \let\ptexlbrace=\{
  35. \let\ptexrbrace=\}
  36. \let\ptexdots=\dots
  37. \let\ptexdot=\.
  38. \let\ptexstar=\*
  39. \let\ptexend=\end
  40. \let\ptexbullet=\bullet
  41. \let\ptexb=\b
  42. \let\ptexc=\c
  43. \let\ptexi=\i
  44. \let\ptext=\t
  45. \let\ptexl=\l
  46. \let\ptexL=\L
  47.  
  48. \def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
  49.  
  50. \message{Basics,}
  51. \chardef\other=12
  52.  
  53. % If this character appears in an error message or help string, it
  54. % starts a new line in the output.
  55. \newlinechar = `^^J
  56.  
  57. \hyphenation{ap-pen-dix}
  58. \hyphenation{mini-buf-fer mini-buf-fers}
  59. \hyphenation{eshell}
  60.  
  61. % Margin to add to right of even pages, to left of odd pages.
  62. \newdimen \bindingoffset  \bindingoffset=0pt
  63. \newdimen \normaloffset   \normaloffset=\hoffset
  64. \newdimen\pagewidth \newdimen\pageheight
  65. \pagewidth=\hsize \pageheight=\vsize
  66.  
  67. % Sometimes it is convenient to have everything in the transcript file
  68. % and nothing on the terminal.  We don't just call \tracingall here,
  69. % since that produces some useless output on the terminal.
  70. %
  71. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  72. \def\loggingall{\tracingcommands2 \tracingstats2 
  73.    \tracingpages1 \tracingoutput1 \tracinglostchars1 
  74.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1 
  75.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  76. }%
  77.  
  78. %---------------------Begin change-----------------------
  79. %
  80. %%%% For @cropmarks command.
  81. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  82. %
  83. \newdimen\cornerlong \newdimen\cornerthick
  84. \newdimen \topandbottommargin
  85. \newdimen \outerhsize \newdimen \outervsize
  86. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  87. \outerhsize=7in
  88. %\outervsize=9.5in
  89. % Alternative @smallbook page size is 9.25in
  90. \outervsize=9.25in
  91. \topandbottommargin=.75in
  92. %
  93. %---------------------End change-----------------------
  94.  
  95. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  96. % does insertions itself, but you have to call it yourself.
  97. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  98. \def\onepageout#1{\hoffset=\normaloffset
  99. \ifodd\pageno  \advance\hoffset by \bindingoffset
  100. \else \advance\hoffset by -\bindingoffset\fi
  101. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  102. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  103. {\let\hsize=\pagewidth \makefootline}}}%
  104. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  105.  
  106. %%%% For @cropmarks command %%%%
  107.  
  108. % Here is a modification of the main output routine for Near East Publications
  109. % This provides right-angle cropmarks at all four corners.
  110. % The contents of the page are centerlined into the cropmarks,
  111. % and any desired binding offset is added as an \hskip on either
  112. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  113. %
  114. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  115.          \shipout
  116.          \vbox to \outervsize{\hsize=\outerhsize
  117.                  \vbox{\line{\ewtop\hfill\ewtop}}
  118.                  \nointerlineskip
  119.                  \line{\vbox{\moveleft\cornerthick\nstop}
  120.                        \hfill
  121.                        \vbox{\moveright\cornerthick\nstop}}
  122.                  \vskip \topandbottommargin
  123.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  124.             \vbox{
  125.             {\let\hsize=\pagewidth \makeheadline}
  126.             \pagebody{#1}
  127.             {\let\hsize=\pagewidth \makefootline}}
  128.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  129.          \vskip \topandbottommargin plus1fill minus1fill
  130.                  \boxmaxdepth\cornerthick
  131.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  132.                        \hfill
  133.                        \vbox{\moveright\cornerthick\nsbot}}
  134.                  \nointerlineskip
  135.                  \vbox{\line{\ewbot\hfill\ewbot}}
  136.     }
  137.   \advancepageno 
  138.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  139. %
  140. % Do @cropmarks to get crop marks
  141. \def\cropmarks{\let\onepageout=\croppageout }
  142.  
  143. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  144. {\catcode`\@ =11
  145. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  146. \dimen@=\dp#1 \unvbox#1
  147. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  148. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  149. }
  150.  
  151. %
  152. % Here are the rules for the cropmarks.  Note that they are
  153. % offset so that the space between them is truly \outerhsize or \outervsize
  154. % (P. A. MacKay, 12 November, 1986)
  155. %
  156. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  157. \def\nstop{\vbox
  158.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  159. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  160. \def\nsbot{\vbox
  161.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  162.  
  163. % Parse an argument, then pass it to #1.
  164. % The argument can be delimited with [...] or with "..." or braces
  165. % or it can be a whole line.
  166. % #1 should be a macro which expects
  167. % an ordinary undelimited TeX argument.
  168.  
  169. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx}
  170.  
  171. \def\parseargx{%
  172. \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else%
  173. \aftergroup \parseargline %
  174. \fi \endgroup}
  175.  
  176. {\obeyspaces %
  177. \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}}
  178.  
  179. \gdef\obeyedspace{\ }
  180.  
  181. \def\parseargline{\begingroup \obeylines \parsearglinex}
  182. {\obeylines %
  183. \gdef\parsearglinex #1^^M{\endgroup \next {#1}}}
  184.  
  185. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  186.  
  187. %% These are used to keep @begin/@end levels from running away
  188. %% Call \inENV within environments (after a \begingroup)
  189. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  190. \def\ENVcheck{%
  191. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  192. \endgroup\fi} % This is not perfect, but it should reduce lossage
  193.  
  194. % @begin foo  is the same as @foo, for now.
  195. \newhelp\EMsimple{Type <Return> to continue}
  196.  
  197. \outer\def\begin{\parsearg\beginxxx}
  198.  
  199. \def\beginxxx #1{%
  200. \expandafter\ifx\csname #1\endcsname\relax
  201. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  202. \csname #1\endcsname\fi}
  203.  
  204. %% @end foo executes the definition of \Efoo.
  205. %% foo can be delimited by doublequotes or brackets.
  206.  
  207. \def\end{\parsearg\endxxx}
  208.  
  209. \def\endxxx #1{%
  210. \expandafter\ifx\csname E#1\endcsname\relax
  211. \expandafter\ifx\csname #1\endcsname\relax
  212. \errmessage{Undefined command @end #1}\else
  213. \errorE{#1}\fi\fi
  214. \csname E#1\endcsname}
  215. \def\errorE#1{
  216. {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}}
  217.  
  218. % Single-spacing is done by various environments.
  219.  
  220. \newskip\singlespaceskip \singlespaceskip = \baselineskip
  221. \def\singlespace{%
  222. {\advance \baselineskip by -\singlespaceskip
  223. \kern \baselineskip}%
  224. \baselineskip=\singlespaceskip
  225. }
  226.  
  227. %% Simple single-character @ commands
  228.  
  229. % @@ prints an @
  230. % Kludge this until the fonts are right (grr).
  231. \def\@{{\tt \char '100}}
  232.  
  233. % Define @` and @' to be the same as ` and '
  234. % but suppressing ligatures.
  235. \def\`{{`}}
  236. \def\'{{'}}
  237.  
  238. % Used to generate quoted braces.
  239.  
  240. \def\mylbrace {{\tt \char '173}}
  241. \def\myrbrace {{\tt \char '175}}
  242. \let\{=\mylbrace
  243. \let\}=\myrbrace
  244.  
  245. % @: forces normal size whitespace following.
  246. \def\:{\spacefactor=1000 }
  247.  
  248. % @* forces a line break.
  249. \def\*{\hfil\break\hbox{}\ignorespaces}
  250.  
  251. % @. is an end-of-sentence period.
  252. \def\.{.\spacefactor=3000 }
  253.  
  254. % @w prevents a word break.  Without the \leavevmode, @w at the
  255. % beginning of a paragraph, when TeX is still in vertical mode, would
  256. % produce a whole line of output instead of starting the paragraph.
  257. \def\w#1{\leavevmode\hbox{#1}}
  258.  
  259. % @group ... @end group forces ... to be all on one page, by enclosing
  260. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  261. % to keep its height that of a normal line.  According to the rules for
  262. % \topskip (p.114 of the TeXbook), the glue inserted is
  263. % max (\topskip - \ht (first item), 0).  If that height is large,
  264. % therefore, no glue is inserted, and the space between the headline and
  265. % the text is small, which looks bad.
  266. \def\group{\begingroup
  267.   \ifnum\catcode13=\active \else
  268.     \errhelp = \groupinvalidhelp
  269.     \errmessage{@group invalid in context where filling is enabled}%
  270.   \fi
  271.   \def\Egroup{\egroup\endgroup}%
  272.   \vtop\bgroup
  273.   % We do @comment here in case we are called inside an environment,
  274.   % such as @example, where each end-of-line in the input causes an
  275.   % end-of-line in the output.  We don't want the end-of-line after
  276.   % the `@group' to put extra space in the output.  Since @group
  277.   % should appear on a line by itself (according to the Texinfo
  278.   % manual), we don't worry about eating any user text.
  279.   \comment
  280. }
  281. %
  282. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  283. % message, so this ends up printing `@group can only ...'.
  284. \newhelp\groupinvalidhelp{%
  285. group can only be used in environments such as @example,^^J%
  286. where each line of input produces a line of output.}
  287.  
  288. % @need space-in-mils
  289. % forces a page break if there is not space-in-mils remaining.
  290.  
  291. \newdimen\mil  \mil=0.001in
  292.  
  293. \def\need{\parsearg\needx}
  294.  
  295. % Old definition--didn't work.
  296. %\def\needx #1{\par %
  297. %% This method tries to make TeX break the page naturally
  298. %% if the depth of the box does not fit.
  299. %{\baselineskip=0pt%
  300. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  301. %\prevdepth=-1000pt
  302. %}}
  303.  
  304. \def\needx#1{%
  305.   % Go into vertical mode, so we don't make a big box in the middle of a
  306.   % paragraph.
  307.   \par
  308.   %
  309.   % Don't add any leading before our big empty box, but allow a page
  310.   % break, since the best break might be right here.
  311.   \allowbreak
  312.   \nointerlineskip
  313.   \vtop to #1\mil{\vfil}%
  314.   % 
  315.   % TeX does not even consider page breaks if a penalty added to the
  316.   % main vertical list is 10000 or more.  But in order to see if the
  317.   % empty box we just added fits on the page, we must make it consider
  318.   % page breaks.  On the other hand, we don't want to actually break the
  319.   % page after the empty box.  So we use a penalty of 9999.
  320.   % 
  321.   % There is an extremely small chance that TeX will actually break the
  322.   % page at this \penalty, if there are no other feasible breakpoints in
  323.   % sight.  (If the user is using lots of big @group commands, which
  324.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  325.   % good page breaking, for example.)  However, I could not construct an
  326.   % example where a page broke at this \penalty; if it happens in a real
  327.   % document, then we can reconsider our strategy.
  328.   \penalty9999
  329.   %
  330.   % Back up by the size of the box, whether we did a page break or not.
  331.   \kern -#1\mil
  332.   %
  333.   % Do not allow a page break right after this kern.
  334.   \nobreak
  335. }
  336.  
  337. % @br   forces paragraph break
  338.  
  339. \let\br = \par
  340.  
  341. % @dots{}  output some dots
  342.  
  343. \def\dots{$\ldots$}
  344.  
  345. % @page    forces the start of a new page
  346.  
  347. \def\page{\par\vfill\supereject}
  348.  
  349. % @exdent text....
  350. % outputs text on separate line in roman font, starting at standard page margin
  351.  
  352. % This records the amount of indent in the innermost environment.
  353. % That's how much \exdent should take out.
  354. \newskip\exdentamount
  355.  
  356. % This defn is used inside fill environments such as @defun.
  357. \def\exdent{\parsearg\exdentyyy}
  358. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  359.  
  360. % This defn is used inside nofill environments such as @example.
  361. \def\nofillexdent{\parsearg\nofillexdentyyy}
  362. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  363. \leftline{\hskip\leftskip{\rm#1}}}}
  364.  
  365. %\hbox{{\rm#1}}\hfil\break}}
  366.  
  367. % @include file    insert text of that file as input.
  368.  
  369. \def\include{\parsearg\includezzz}
  370. \def\includezzz #1{{\def\thisfile{#1}\input #1
  371. }}
  372.  
  373. \def\thisfile{}
  374.  
  375. % @center line   outputs that line, centered
  376.  
  377. \def\center{\parsearg\centerzzz}
  378. \def\centerzzz #1{{\advance\hsize by -\leftskip
  379. \advance\hsize by -\rightskip
  380. \centerline{#1}}}
  381.  
  382. % @sp n   outputs n lines of vertical space
  383.  
  384. \def\sp{\parsearg\spxxx}
  385. \def\spxxx #1{\par \vskip #1\baselineskip}
  386.  
  387. % @comment ...line which is ignored...
  388. % @c is the same as @comment
  389. % @ignore ... @end ignore  is another way to write a comment
  390.  
  391. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  392. \parsearg \commentxxx}
  393.  
  394. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  395.  
  396. \let\c=\comment
  397.  
  398. % Prevent errors for section commands.
  399. % Used in @ignore and in failing conditionals.
  400. \def\ignoresections{%
  401. \let\chapter=\relax
  402. \let\unnumbered=\relax
  403. \let\top=\relax
  404. \let\unnumberedsec=\relax
  405. \let\unnumberedsection=\relax
  406. \let\unnumberedsubsec=\relax
  407. \let\unnumberedsubsection=\relax
  408. \let\unnumberedsubsubsec=\relax
  409. \let\unnumberedsubsubsection=\relax
  410. \let\section=\relax
  411. \let\subsec=\relax
  412. \let\subsubsec=\relax
  413. \let\subsection=\relax
  414. \let\subsubsection=\relax
  415. \let\appendix=\relax
  416. \let\appendixsec=\relax
  417. \let\appendixsection=\relax
  418. \let\appendixsubsec=\relax
  419. \let\appendixsubsection=\relax
  420. \let\appendixsubsubsec=\relax
  421. \let\appendixsubsubsection=\relax
  422. \let\contents=\relax
  423. \let\smallbook=\relax
  424. \let\titlepage=\relax
  425. }
  426.  
  427. \def\ignore{\begingroup\ignoresections
  428. % Make sure that spaces turn into tokens that match what \ignorexxx wants.
  429. \catcode32=10
  430. \ignorexxx}
  431. \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces}
  432.  
  433. \def\direntry{\begingroup\direntryxxx}
  434. \long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces}
  435.  
  436. % Conditionals to test whether a flag is set.
  437.  
  438. \def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx}
  439.  
  440. \def\ifsetxxx #1{\endgroup
  441. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail
  442. \else \let\temp=\relax \fi
  443. \temp}
  444. \def\Eifset{}
  445. \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx}
  446. \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces}
  447.  
  448. \def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx}
  449.  
  450. \def\ifclearxxx #1{\endgroup
  451. \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax
  452. \else \let\temp=\ifclearfail \fi
  453. \temp}
  454. \def\Eifclear{}
  455. \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx}
  456. \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces}
  457.  
  458. % @set foo     to set the flag named foo.
  459. % @clear foo   to clear the flag named foo.
  460. \def\set{\parsearg\setxxx}
  461. \def\setxxx #1{
  462. \expandafter\let\csname IF#1\endcsname=\set}
  463.  
  464. \def\clear{\parsearg\clearxxx}
  465. \def\clearxxx #1{
  466. \expandafter\let\csname IF#1\endcsname=\relax}
  467.  
  468. % Some texinfo constructs that are trivial in tex
  469.  
  470. \def\iftex{}
  471. \def\Eiftex{}
  472. \def\ifinfo{\begingroup\ignoresections\ifinfoxxx}
  473. \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces}
  474.  
  475. \long\def\menu #1\end menu{}
  476. \def\asis#1{#1}
  477.  
  478. % @math means output in math mode.
  479. % We don't use $'s directly in the definition of \math because control
  480. % sequences like \math are expanded when the toc file is written.  Then,
  481. % we read the toc file back, the $'s will be normal characters (as they
  482. % should be, according to the definition of Texinfo).  So we must use a
  483. % control sequence to switch into and out of math mode.
  484. % This isn't quite enough for @math to work properly in indices, but it
  485. % seems unlikely it will ever be needed there.
  486. \let\implicitmath = $
  487. \def\math#1{\implicitmath #1\implicitmath}
  488.  
  489. \def\node{\ENVcheck\parsearg\nodezzz}
  490. \def\nodezzz#1{\nodexxx [#1,]}
  491. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  492. \let\lastnode=\relax
  493.  
  494. \def\donoderef{\ifx\lastnode\relax\else
  495. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  496. \let\lastnode=\relax}
  497.  
  498. \def\unnumbnoderef{\ifx\lastnode\relax\else
  499. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  500. \let\lastnode=\relax}
  501.  
  502. \def\appendixnoderef{\ifx\lastnode\relax\else
  503. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  504. \let\lastnode=\relax}
  505.  
  506. \let\refill=\relax
  507.   
  508. % @setfilename is done at the beginning of every texinfo file.
  509. % So open here the files we need to have open while reading the input.
  510. % This makes it possible to make a .fmt file for texinfo.
  511. \def\setfilename{%
  512.    \readauxfile
  513.    \opencontents
  514.    \openindices
  515.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  516.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  517.    \comment % Ignore the actual filename.
  518. }
  519.  
  520. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  521.  
  522. \def\inforef #1{\inforefzzz #1,,,,**}
  523. \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}},
  524.   node \samp{\losespace#1{}}}
  525. \def\losespace #1{#1}
  526.  
  527. \message{fonts,}
  528.  
  529. % Font-change commands.
  530.  
  531. % Texinfo supports the sans serif font style, which plain TeX does not.
  532. % So we set up a \sf analogous to plain's \rm, etc.
  533. \newfam\sffam
  534. \def\sf{\fam=\sffam \tensf}
  535. \let\li = \sf % Sometimes we call it \li, not \sf.
  536.  
  537. %% Try out Computer Modern fonts at \magstephalf
  538. \let\mainmagstep=\magstephalf
  539.  
  540. \ifx\bigger\relax
  541. \let\mainmagstep=\magstep1
  542. \font\textrm=cmr12
  543. \font\texttt=cmtt12
  544. \else
  545. \font\textrm=cmr10 scaled \mainmagstep
  546. \font\texttt=cmtt10 scaled \mainmagstep
  547. \fi
  548. % Instead of cmb10, you many want to use cmbx10.
  549. % cmbx10 is a prettier font on its own, but cmb10
  550. % looks better when embedded in a line with cmr10.
  551. \font\textbf=cmb10 scaled \mainmagstep 
  552. \font\textit=cmti10 scaled \mainmagstep
  553. \font\textsl=cmsl10 scaled \mainmagstep
  554. \font\textsf=cmss10 scaled \mainmagstep
  555. \font\textsc=cmcsc10 scaled \mainmagstep
  556. \font\texti=cmmi10 scaled \mainmagstep
  557. \font\textsy=cmsy10 scaled \mainmagstep
  558.  
  559. % A few fonts for @defun, etc.
  560. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  561. \font\deftt=cmtt10 scaled \magstep1
  562. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  563.  
  564. % Fonts for indices and small examples.
  565. % We actually use the slanted font rather than the italic, 
  566. % because texinfo normally uses the slanted fonts for that.
  567. % Do not make many font distinctions in general in the index, since they
  568. % aren't very useful.
  569. \font\ninett=cmtt9
  570. \font\indrm=cmr9
  571. \font\indit=cmsl9
  572. \let\indsl=\indit
  573. \let\indtt=\ninett
  574. \let\indsf=\indrm
  575. \let\indbf=\indrm
  576. \let\indsc=\indrm
  577. \font\indi=cmmi9
  578. \font\indsy=cmsy9
  579.  
  580. % Fonts for headings
  581. \font\chaprm=cmbx12 scaled \magstep2
  582. \font\chapit=cmti12 scaled \magstep2
  583. \font\chapsl=cmsl12 scaled \magstep2
  584. \font\chaptt=cmtt12 scaled \magstep2
  585. \font\chapsf=cmss12 scaled \magstep2
  586. \let\chapbf=\chaprm
  587. \font\chapsc=cmcsc10 scaled\magstep3
  588. \font\chapi=cmmi12 scaled \magstep2
  589. \font\chapsy=cmsy10 scaled \magstep3
  590.  
  591. \font\secrm=cmbx12 scaled \magstep1
  592. \font\secit=cmti12 scaled \magstep1
  593. \font\secsl=cmsl12 scaled \magstep1
  594. \font\sectt=cmtt12 scaled \magstep1
  595. \font\secsf=cmss12 scaled \magstep1
  596. \font\secbf=cmbx12 scaled \magstep1
  597. \font\secsc=cmcsc10 scaled\magstep2
  598. \font\seci=cmmi12 scaled \magstep1
  599. \font\secsy=cmsy10 scaled \magstep2
  600.  
  601. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  602. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  603. % \font\ssecsl=cmsl10 scaled \magstep1
  604. % \font\ssectt=cmtt10 scaled \magstep1
  605. % \font\ssecsf=cmss10 scaled \magstep1
  606.  
  607. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  608. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  609. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  610. %\font\ssectt=cmtt10 scaled 1315
  611. %\font\ssecsf=cmss10 scaled 1315
  612.  
  613. %\let\ssecbf=\ssecrm
  614.  
  615. \font\ssecrm=cmbx12 scaled \magstephalf
  616. \font\ssecit=cmti12 scaled \magstephalf
  617. \font\ssecsl=cmsl12 scaled \magstephalf
  618. \font\ssectt=cmtt12 scaled \magstephalf
  619. \font\ssecsf=cmss12 scaled \magstephalf
  620. \font\ssecbf=cmbx12 scaled \magstephalf
  621. \font\ssecsc=cmcsc10 scaled \magstep1 
  622. \font\sseci=cmmi12 scaled \magstephalf
  623. \font\ssecsy=cmsy10 scaled \magstep1
  624. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  625. % but that is not a standard magnification.
  626.  
  627. % Fonts for title page:
  628. \font\titlerm = cmbx12 scaled \magstep3
  629. \let\authorrm = \secrm
  630.  
  631. % In order for the font changes to affect most math symbols and letters,
  632. % we have to define the \textfont of the standard families.  Since
  633. % texinfo doesn't allow for producing subscripts and superscripts, we
  634. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  635. % also require loading a lot more fonts).
  636. \def\resetmathfonts{%
  637.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  638.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  639.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  640. }
  641.  
  642.  
  643. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  644. % of just \STYLE.  We do this so that font changes will continue to work
  645. % in math mode, where it is the current \fam that is relevant in most
  646. % cases, not the current.  Plain TeX does, for example,
  647. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  648. % to redefine \bf itself.  
  649. \def\textfonts{%
  650.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  651.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  652.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  653.   \resetmathfonts}
  654. \def\chapfonts{%
  655.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 
  656.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  657.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  658.   \resetmathfonts}
  659. \def\secfonts{%
  660.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  661.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  662.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  663.   \resetmathfonts}
  664. \def\subsecfonts{%
  665.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  666.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  667.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  668.   \resetmathfonts}
  669. \def\indexfonts{%
  670.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  671.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  672.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  673.   \resetmathfonts}
  674.  
  675. % Set up the default fonts, so we can use them for creating boxes.
  676. \textfonts
  677.  
  678. % Count depth in font-changes, for error checks
  679. \newcount\fontdepth \fontdepth=0
  680.  
  681. % Fonts for short table of contents.
  682. \font\shortcontrm=cmr12
  683. \font\shortcontbf=cmbx12
  684. \font\shortcontsl=cmsl12
  685.  
  686. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  687. %% serif) and @ii for TeX italic
  688.  
  689. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  690. % unless the following character is such as not to need one.
  691. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  692. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  693.  
  694. \let\i=\smartitalic
  695. \let\var=\smartitalic
  696. \let\dfn=\smartitalic
  697. \let\emph=\smartitalic
  698. \let\cite=\smartitalic
  699.  
  700. \def\b#1{{\bf #1}}
  701. \let\strong=\b
  702.  
  703. \def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null}
  704. \let\ttfont = \t
  705. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  706. \def\samp #1{`\tclose{#1}'\null}
  707. \def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null}
  708. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  709.  
  710. \let\file=\samp
  711.  
  712. % @code is a modification of @t,
  713. % which makes spaces the same size as normal in the surrounding text.
  714. \newdimen\tclosesave
  715. \newdimen\tcloserm
  716. \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font
  717. \fontdimen2\font=\tcloserm
  718. % prevent breaking lines at hyphens.
  719. \exhyphenpenalty=10000
  720. \def\ {{\fontdimen2\font=\tclosesave{} }}%
  721.  \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null}
  722. \let\code=\tclose
  723. %\let\exp=\tclose  %Was temporary
  724.  
  725. % @kbd is like @code, except that if the argument is just one @key command, 
  726. % then @kbd has no effect.
  727.  
  728. \def\xkey{\key}
  729. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  730. \ifx\one\xkey\ifx\threex\three \key{#2}%
  731. \else\tclose{\look}\fi
  732. \else\tclose{\look}\fi}
  733.  
  734. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  735. % argument is to make the input look right: @dmn{pt} instead of
  736. % @dmn{}pt.
  737. \def\dmn#1{\thinspace #1}
  738.  
  739. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  740.  
  741. \def\l#1{{\li #1}\null}        % 
  742.  
  743. \def\r#1{{\rm #1}}        % roman font
  744. % Use of \lowercase was suggested.
  745. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  746. \def\ii#1{{\it #1}}        % italic font
  747.  
  748. \message{page headings,}
  749.  
  750. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  751. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  752.  
  753. % First the title page.  Must do @settitle before @titlepage.
  754. \def\titlefont#1{{\titlerm #1}}
  755.  
  756. \newtoks\realeverypar
  757. \newif\ifseenauthor
  758. \newif\iffinishedtitlepage
  759.  
  760. \def\titlepage{\begingroup \parindent=0pt \textfonts
  761.    \let\subtitlerm=\tenrm
  762. % I deinstalled the following change because \cmr12 is undefined.
  763. % This change was not in the ChangeLog anyway.  --rms.
  764. %   \let\subtitlerm=\cmr12
  765.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  766.    %
  767.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  768.    %
  769.    % Leave some space at the very top of the page.
  770.    \vglue\titlepagetopglue
  771.    %
  772.    % Now you can print the title using @title.
  773.    \def\title{\parsearg\titlezzz}%
  774.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  775.             % print a rule at the page bottom also.
  776.             \finishedtitlepagefalse
  777.             \vskip4pt \hrule height 4pt \vskip4pt}%
  778.    % No rule at page bottom unless we print one at the top with @title.
  779.    \finishedtitlepagetrue
  780.    %
  781.    % Now you can put text using @subtitle.
  782.    \def\subtitle{\parsearg\subtitlezzz}%
  783.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  784.    %
  785.    % @author should come last, but may come many times.
  786.    \def\author{\parsearg\authorzzz}%
  787.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  788.       {\authorfont \leftline{##1}}}%
  789.    %  
  790.    % Most title ``pages'' are actually two pages long, with space
  791.    % at the top of the second.  We don't want the ragged left on the second.
  792.    \let\oldpage = \page
  793.    \def\page{%
  794.       \iffinishedtitlepage\else
  795.      \finishtitlepage
  796.       \fi
  797.       \oldpage
  798.       \let\page = \oldpage
  799.       \hbox{}}%
  800. %   \def\page{\oldpage \hbox{}}
  801. }
  802.  
  803. \def\Etitlepage{%
  804.    \iffinishedtitlepage\else
  805.       \finishtitlepage
  806.    \fi
  807.    % It is important to do the page break before ending the group,
  808.    % because the headline and footline are only empty inside the group.
  809.    % If we use the new definition of \page, we always get a blank page
  810.    % after the title page, which we certainly don't want.
  811.    \oldpage
  812.    \endgroup
  813.    \HEADINGSon
  814. }
  815.  
  816. \def\finishtitlepage{%
  817.    \vskip4pt \hrule height 2pt
  818.    \vskip\titlepagebottomglue
  819.    \finishedtitlepagetrue
  820. }
  821.  
  822. %%% Set up page headings and footings.
  823.  
  824. \let\thispage=\folio
  825.  
  826. \newtoks \evenheadline    % Token sequence for heading line of even pages
  827. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  828. \newtoks \evenfootline    % Token sequence for footing line of even pages
  829. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  830.  
  831. % Now make Tex use those variables
  832. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  833.                             \else \the\evenheadline \fi}}
  834. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  835.                             \else \the\evenfootline \fi}\HEADINGShook}
  836. \let\HEADINGShook=\relax
  837.  
  838. % Commands to set those variables.
  839. % For example, this is what  @headings on  does
  840. % @evenheading @thistitle|@thispage|@thischapter
  841. % @oddheading @thischapter|@thispage|@thistitle
  842. % @evenfooting @thisfile||
  843. % @oddfooting ||@thisfile
  844.  
  845. \def\evenheading{\parsearg\evenheadingxxx}
  846. \def\oddheading{\parsearg\oddheadingxxx}
  847. \def\everyheading{\parsearg\everyheadingxxx}
  848.  
  849. \def\evenfooting{\parsearg\evenfootingxxx}
  850. \def\oddfooting{\parsearg\oddfootingxxx}
  851. \def\everyfooting{\parsearg\everyfootingxxx}
  852.  
  853. {\catcode`\@=0 %
  854.  
  855. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  856. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  857. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  858.  
  859. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  860. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  861. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  862.  
  863. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  864. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  865. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  866. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  867.  
  868. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  869. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  870. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  871.  
  872. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  873. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  874. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  875.  
  876. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  877. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  878. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  879. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  880. %
  881. }% unbind the catcode of @.
  882.  
  883. % @headings double    turns headings on for double-sided printing.
  884. % @headings single    turns headings on for single-sided printing.
  885. % @headings off        turns them off.
  886. % @headings on        same as @headings double, retained for compatibility.
  887. % @headings after    turns on double-sided headings after this page.
  888. % @headings doubleafter    turns on double-sided headings after this page.
  889. % @headings singleafter turns on single-sided headings after this page.
  890. % By default, they are off.
  891.  
  892. \def\headings #1 {\csname HEADINGS#1\endcsname}
  893.  
  894. \def\HEADINGSoff{
  895. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  896. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  897. \HEADINGSoff
  898. % When we turn headings on, set the page number to 1.
  899. % For double-sided printing, put current file name in lower left corner,
  900. % chapter name on inside top of right hand pages, document
  901. % title on inside top of left hand pages, and page numbers on outside top
  902. % edge of all pages.
  903. \def\HEADINGSdouble{
  904. %\pagealignmacro
  905. \global\pageno=1
  906. \global\evenfootline={\hfil}
  907. \global\oddfootline={\hfil}
  908. \global\evenheadline={\line{\folio\hfil\thistitle}}
  909. \global\oddheadline={\line{\thischapter\hfil\folio}}
  910. }
  911. % For single-sided printing, chapter title goes across top left of page,
  912. % page number on top right.
  913. \def\HEADINGSsingle{
  914. %\pagealignmacro
  915. \global\pageno=1
  916. \global\evenfootline={\hfil}
  917. \global\oddfootline={\hfil}
  918. \global\evenheadline={\line{\thischapter\hfil\folio}}
  919. \global\oddheadline={\line{\thischapter\hfil\folio}}
  920. }
  921. \def\HEADINGSon{\HEADINGSdouble}
  922.  
  923. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  924. \let\HEADINGSdoubleafter=\HEADINGSafter
  925. \def\HEADINGSdoublex{%
  926. \global\evenfootline={\hfil}
  927. \global\oddfootline={\hfil}
  928. \global\evenheadline={\line{\folio\hfil\thistitle}}
  929. \global\oddheadline={\line{\thischapter\hfil\folio}}
  930. }
  931.  
  932. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  933. \def\HEADINGSsinglex{%
  934. \global\evenfootline={\hfil}
  935. \global\oddfootline={\hfil}
  936. \global\evenheadline={\line{\thischapter\hfil\folio}}
  937. \global\oddheadline={\line{\thischapter\hfil\folio}}
  938. }
  939.  
  940. % Subroutines used in generating headings
  941. % Produces Day Month Year style of output.
  942. \def\today{\number\day\space
  943. \ifcase\month\or
  944. January\or February\or March\or April\or May\or June\or
  945. July\or August\or September\or October\or November\or December\fi
  946. \space\number\year}
  947.  
  948. % Use this if you want the Month Day, Year style of output.
  949. %\def\today{\ifcase\month\or
  950. %January\or February\or March\or April\or May\or June\or
  951. %July\or August\or September\or October\or November\or December\fi
  952. %\space\number\day, \number\year}
  953.  
  954. % @settitle line...  specifies the title of the document, for headings
  955. % It generates no output of its own
  956.  
  957. \def\thistitle{No Title}
  958. \def\settitle{\parsearg\settitlezzz}
  959. \def\settitlezzz #1{\gdef\thistitle{#1}}
  960.  
  961. \message{tables,}
  962.  
  963. % @tabs -- simple alignment
  964.  
  965. % These don't work.  For one thing, \+ is defined as outer.
  966. % So these macros cannot even be defined.
  967.  
  968. %\def\tabs{\parsearg\tabszzz}
  969. %\def\tabszzz #1{\settabs\+#1\cr}
  970. %\def\tabline{\parsearg\tablinezzz}
  971. %\def\tablinezzz #1{\+#1\cr}
  972. %\def\&{&}
  973.  
  974. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  975.  
  976. % default indentation of table text
  977. \newdimen\tableindent \tableindent=.8in
  978. % default indentation of @itemize and @enumerate text
  979. \newdimen\itemindent  \itemindent=.3in
  980. % margin between end of table item and start of table text.
  981. \newdimen\itemmargin  \itemmargin=.1in
  982.  
  983. % used internally for \itemindent minus \itemmargin
  984. \newdimen\itemmax
  985.  
  986. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  987. % these defs.
  988. % They also define \itemindex
  989. % to index the item name in whatever manner is desired (perhaps none).
  990.  
  991. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  992. \def\internalBitemx{\par \parsearg\itemzzz}
  993.  
  994. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  995. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz}
  996.  
  997. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  998. \def\internalBkitemx{\par \parsearg\kitemzzz}
  999.  
  1000. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1001.                  \itemzzz {#1}}
  1002.  
  1003. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1004.                  \itemzzz {#1}}
  1005.  
  1006. \def\itemzzz #1{\begingroup %
  1007.   \advance\hsize by -\rightskip
  1008.   \advance\hsize by -\tableindent
  1009.   \setbox0=\hbox{\itemfont{#1}}%
  1010.   \itemindex{#1}%
  1011.   \nobreak % This prevents a break before @itemx.
  1012.   %
  1013.   % Be sure we are not still in the middle of a paragraph.
  1014.   \parskip=0in
  1015.   \par
  1016.   %
  1017.   % If the item text does not fit in the space we have, put it on a line
  1018.   % by itself, and do not allow a page break either before or after that
  1019.   % line.  We do not start a paragraph here because then if the next
  1020.   % command is, e.g., @kindex, the whatsit would get put into the
  1021.   % horizontal list on a line by itself, resulting in extra blank space.
  1022.   \ifdim \wd0>\itemmax
  1023.     \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0
  1024.     \nobreak
  1025.   \else
  1026.     % The item text fits into the space.  Start a paragraph, so that the
  1027.     % following text (if any) will end up on the same line.  Since that
  1028.     % text will be indented by \tableindent, we make the item text be in
  1029.     % a zero-width box.
  1030.     \noindent
  1031.     \rlap{\hskip -\tableindent\box0}%
  1032.   \fi
  1033.   \endgroup
  1034. }
  1035.  
  1036. \def\item{\errmessage{@item while not in a table}}
  1037. \def\itemx{\errmessage{@itemx while not in a table}}
  1038. \def\kitem{\errmessage{@kitem while not in a table}}
  1039. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1040. \def\xitem{\errmessage{@xitem while not in a table}}
  1041. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1042.  
  1043. %% Contains a kludge to get @end[description] to work
  1044. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1045.  
  1046. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1047. {\obeylines\obeyspaces%
  1048. \gdef\tablex #1^^M{%
  1049. \tabley\dontindex#1        \endtabley}}
  1050.  
  1051. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1052. {\obeylines\obeyspaces%
  1053. \gdef\ftablex #1^^M{%
  1054. \tabley\fnitemindex#1        \endtabley
  1055. \def\Eftable{\endgraf\endgroup\afterenvbreak}%
  1056. \let\Etable=\relax}}
  1057.  
  1058. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1059. {\obeylines\obeyspaces%
  1060. \gdef\vtablex #1^^M{%
  1061. \tabley\vritemindex#1        \endtabley
  1062. \def\Evtable{\endgraf\endgroup\afterenvbreak}%
  1063. \let\Etable=\relax}}
  1064.  
  1065. \def\dontindex #1{}
  1066. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1067. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1068.  
  1069. {\obeyspaces %
  1070. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1071. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1072.  
  1073. \def\tablez #1#2#3#4#5#6{%
  1074. \aboveenvbreak %
  1075. \begingroup %
  1076. \def\Edescription{\Etable}% Neccessary kludge.
  1077. \let\itemindex=#1%
  1078. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1079. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1080. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1081. \def\itemfont{#2}%
  1082. \itemmax=\tableindent %
  1083. \advance \itemmax by -\itemmargin %
  1084. \advance \leftskip by \tableindent %
  1085. \exdentamount=\tableindent
  1086. \parindent = 0pt
  1087. \parskip = \smallskipamount
  1088. \ifdim \parskip=0pt \parskip=2pt \fi%
  1089. \def\Etable{\endgraf\endgroup\afterenvbreak}%
  1090. \let\item = \internalBitem %
  1091. \let\itemx = \internalBitemx %
  1092. \let\kitem = \internalBkitem %
  1093. \let\kitemx = \internalBkitemx %
  1094. \let\xitem = \internalBxitem %
  1095. \let\xitemx = \internalBxitemx %
  1096. }
  1097.  
  1098. % This is the counter used by @enumerate, which is really @itemize
  1099.  
  1100. \newcount \itemno
  1101.  
  1102. \def\itemize{\parsearg\itemizezzz}
  1103.  
  1104. \def\itemizezzz #1{%
  1105.   \begingroup % ended by the @end itemsize
  1106.   \itemizey {#1}{\Eitemize}
  1107. }
  1108.  
  1109. \def\itemizey #1#2{%
  1110. \aboveenvbreak %
  1111. \itemmax=\itemindent %
  1112. \advance \itemmax by -\itemmargin %
  1113. \advance \leftskip by \itemindent %
  1114. \exdentamount=\itemindent
  1115. \parindent = 0pt %
  1116. \parskip = \smallskipamount %
  1117. \ifdim \parskip=0pt \parskip=2pt \fi%
  1118. \def#2{\endgraf\endgroup\afterenvbreak}%
  1119. \def\itemcontents{#1}%
  1120. \let\item=\itemizeitem}
  1121.  
  1122. \def\bullet{$\ptexbullet$}
  1123. \def\minus{$-$}
  1124.  
  1125. % Set sfcode to normal for the chars that usually have another value.
  1126. % These are `.?!:;,'
  1127. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1128.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1129.  
  1130. % \splitoff TOKENS\endmark defines \first to be the first token in
  1131. % TOKENS, and \rest to be the remainder.
  1132. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1133.  
  1134. % Allow an optional argument of an uppercase letter, lowercase letter,
  1135. % or number, to specify the first label in the enumerated list.  No
  1136. % argument is the same as `1'.
  1137. \def\enumerate{\parsearg\enumeratezzz}
  1138. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1139. \def\enumeratey #1 #2\endenumeratey{%
  1140.   \begingroup % ended by the @end enumerate
  1141.   %
  1142.   % If we were given no argument, pretend we were given `1'.
  1143.   \def\thearg{#1}%
  1144.   \ifx\thearg\empty \def\thearg{1}\fi
  1145.   %
  1146.   % Detect if the argument is a single token.  If so, it might be a
  1147.   % letter.  Otherwise, the only valid thing it can be is a number.
  1148.   % (We will always have one token, because of the test we just made.
  1149.   % This is a good thing, since \splitoff doesn't work given nothing at
  1150.   % all -- the first parameter is undelimited.)
  1151.   \expandafter\splitoff\thearg\endmark
  1152.   \ifx\rest\empty
  1153.     % Only one token in the argument.  It could still be anything.
  1154.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1155.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1156.     %   not equal to itself.
  1157.     % Otherwise, we assume it's a number.
  1158.     % 
  1159.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1160.     % continuing to look for a <number>.
  1161.     % 
  1162.     \ifnum\lccode\expandafter`\thearg=0\relax 
  1163.       \numericenumerate % a number (we hope)
  1164.     \else
  1165.       % It's a letter.
  1166.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1167.         \lowercaseenumerate % lowercase letter
  1168.       \else
  1169.         \uppercaseenumerate % uppercase letter
  1170.       \fi
  1171.     \fi
  1172.   \else
  1173.     % Multiple tokens in the argument.  We hope it's a number.
  1174.     \numericenumerate
  1175.   \fi
  1176. }
  1177.  
  1178. % An @enumerate whose labels are integers.  The starting integer is
  1179. % given in \thearg.
  1180. \def\numericenumerate{%
  1181.   \itemno = \thearg
  1182.   \startenumeration{\the\itemno}%
  1183. }
  1184.  
  1185. % The starting (lowercase) letter is in \thearg.
  1186. \def\lowercaseenumerate{%
  1187.   \itemno = \expandafter`\thearg
  1188.   \startenumeration{%
  1189.     % Be sure we're not beyond the end of the alphabet.
  1190.     \ifnum\itemno=0
  1191.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1192.                   alphabet}%
  1193.     \fi
  1194.     \char\lccode\itemno
  1195.   }%
  1196. }
  1197.  
  1198. % The starting (uppercase) letter is in \thearg.
  1199. \def\uppercaseenumerate{%
  1200.   \itemno = \expandafter`\thearg
  1201.   \startenumeration{%
  1202.     % Be sure we're not beyond the end of the alphabet.
  1203.     \ifnum\itemno=0
  1204.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1205.                   alphabet}
  1206.     \fi
  1207.     \char\uccode\itemno
  1208.   }%
  1209. }
  1210.  
  1211. % Call itemizey, adding a period to the first argument and supplying the
  1212. % common last two arguments.  Also subtract one from the initial value in
  1213. % \itemno, since @item increments \itemno.
  1214. \def\startenumeration#1{%
  1215.   \advance\itemno by -1
  1216.   \itemizey{#1.}\Eenumerate\flushcr
  1217. }
  1218.  
  1219. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1220. % to @enumerate.
  1221. \def\alphaenumerate{\enumerate{a}}
  1222. \def\capsenumerate{\enumerate{A}}
  1223. \def\Ealphaenumerate{\Eenumerate}
  1224. \def\Ecapsenumerate{\Eenumerate}
  1225.  
  1226. % Definition of @item while inside @itemize.
  1227.  
  1228. \def\itemizeitem{%
  1229. \advance\itemno by 1
  1230. {\let\par=\endgraf \smallbreak}%
  1231. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1232. {\parskip=0in \hskip 0pt
  1233. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1234. \vadjust{\penalty 1200}}%
  1235. \flushcr}
  1236.  
  1237. \message{indexing,}
  1238. % Index generation facilities
  1239.  
  1240. % Define \newwrite to be identical to plain tex's \newwrite
  1241. % except not \outer, so it can be used within \newindex.
  1242. {\catcode`\@=11
  1243. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1244.  
  1245. % \newindex {foo} defines an index named foo.
  1246. % It automatically defines \fooindex such that
  1247. % \fooindex ...rest of line... puts an entry in the index foo.
  1248. % It also defines \fooindfile to be the number of the output channel for
  1249. % the file that    accumulates this index.  The file's extension is foo.
  1250. % The name of an index should be no more than 2 characters long
  1251. % for the sake of vms.
  1252.  
  1253. \def\newindex #1{
  1254. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1255. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1256. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1257. \noexpand\doindex {#1}}
  1258. }
  1259.  
  1260. % @defindex foo  ==  \newindex{foo}
  1261.  
  1262. \def\defindex{\parsearg\newindex}
  1263.  
  1264. % Define @defcodeindex, like @defindex except put all entries in @code.
  1265.  
  1266. \def\newcodeindex #1{
  1267. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1268. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1269. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1270. \noexpand\docodeindex {#1}}
  1271. }
  1272.  
  1273. \def\defcodeindex{\parsearg\newcodeindex}
  1274.  
  1275. % @synindex foo bar    makes index foo feed into index bar.
  1276. % Do this instead of @defindex foo if you don't want it as a separate index.
  1277. \def\synindex #1 #2 {%
  1278. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1279. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1280. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1281. \noexpand\doindex {#2}}%
  1282. }
  1283.  
  1284. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1285. % inside @code.
  1286. \def\syncodeindex #1 #2 {%
  1287. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1288. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1289. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1290. \noexpand\docodeindex {#2}}%
  1291. }
  1292.  
  1293. % Define \doindex, the driver for all \fooindex macros.
  1294. % Argument #1 is generated by the calling \fooindex macro,
  1295. %  and it is "foo", the name of the index.
  1296.  
  1297. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1298. % This is because \doind is more useful to call from other macros.
  1299.  
  1300. % There is also \dosubind {index}{topic}{subtopic}
  1301. % which makes an entry in a two-level index such as the operation index.
  1302.  
  1303. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1304. \def\singleindexer #1{\doind{\indexname}{#1}}
  1305.  
  1306. % like the previous two, but they put @code around the argument.
  1307. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1308. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1309.  
  1310. \def\indexdummies{%
  1311. \def\_{{\realbackslash _}}%
  1312. \def\w{\realbackslash w }%
  1313. \def\bf{\realbackslash bf }%
  1314. \def\rm{\realbackslash rm }%
  1315. \def\sl{\realbackslash sl }%
  1316. \def\sf{\realbackslash sf}%
  1317. \def\tt{\realbackslash tt}%
  1318. \def\gtr{\realbackslash gtr}%
  1319. \def\less{\realbackslash less}%
  1320. \def\hat{\realbackslash hat}%
  1321. \def\char{\realbackslash char}%
  1322. \def\TeX{\realbackslash TeX}%
  1323. \def\dots{\realbackslash dots }%
  1324. \def\copyright{\realbackslash copyright }%
  1325. \def\tclose##1{\realbackslash tclose {##1}}%
  1326. \def\code##1{\realbackslash code {##1}}%
  1327. \def\samp##1{\realbackslash samp {##1}}%
  1328. \def\t##1{\realbackslash r {##1}}%
  1329. \def\r##1{\realbackslash r {##1}}%
  1330. \def\i##1{\realbackslash i {##1}}%
  1331. \def\b##1{\realbackslash b {##1}}%
  1332. \def\cite##1{\realbackslash cite {##1}}%
  1333. \def\key##1{\realbackslash key {##1}}%
  1334. \def\file##1{\realbackslash file {##1}}%
  1335. \def\var##1{\realbackslash var {##1}}%
  1336. \def\kbd##1{\realbackslash kbd {##1}}%
  1337. }
  1338.  
  1339. % \indexnofonts no-ops all font-change commands.
  1340. % This is used when outputting the strings to sort the index by.
  1341. \def\indexdummyfont#1{#1}
  1342. \def\indexdummytex{TeX}
  1343. \def\indexdummydots{...}
  1344.  
  1345. \def\indexnofonts{%
  1346. \let\w=\indexdummyfont
  1347. \let\t=\indexdummyfont
  1348. \let\r=\indexdummyfont
  1349. \let\i=\indexdummyfont
  1350. \let\b=\indexdummyfont
  1351. \let\emph=\indexdummyfont
  1352. \let\strong=\indexdummyfont
  1353. \let\cite=\indexdummyfont
  1354. \let\sc=\indexdummyfont
  1355. %Don't no-op \tt, since it isn't a user-level command
  1356. % and is used in the definitions of the active chars like <, >, |...
  1357. %\let\tt=\indexdummyfont
  1358. \let\tclose=\indexdummyfont
  1359. \let\code=\indexdummyfont
  1360. \let\file=\indexdummyfont
  1361. \let\samp=\indexdummyfont
  1362. \let\kbd=\indexdummyfont
  1363. \let\key=\indexdummyfont
  1364. \let\var=\indexdummyfont
  1365. \let\TeX=\indexdummytex
  1366. \let\dots=\indexdummydots
  1367. }
  1368.  
  1369. % To define \realbackslash, we must make \ not be an escape.
  1370. % We must first make another character (@) an escape
  1371. % so we do not become unable to do a definition.
  1372.  
  1373. {\catcode`\@=0 \catcode`\\=\other
  1374. @gdef@realbackslash{\}}
  1375.  
  1376. \let\indexbackslash=0  %overridden during \printindex.
  1377.  
  1378. \def\doind #1#2{%
  1379. {\count10=\lastpenalty %
  1380. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1381. \escapechar=`\\%
  1382. {\let\folio=0% Expand all macros now EXCEPT \folio
  1383. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1384. % so it will be output as is; and it will print as backslash in the indx.
  1385. %
  1386. % Now process the index-string once, with all font commands turned off,
  1387. % to get the string to sort the index by.
  1388. {\indexnofonts
  1389. \xdef\temp1{#2}%
  1390. }%
  1391. % Now produce the complete index entry.  We process the index-string again,
  1392. % this time with font commands expanded, to get what to print in the index.
  1393. \edef\temp{%
  1394. \write \csname#1indfile\endcsname{%
  1395. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1396. \temp }%
  1397. }\penalty\count10}}
  1398.  
  1399. \def\dosubind #1#2#3{%
  1400. {\count10=\lastpenalty %
  1401. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1402. \escapechar=`\\%
  1403. {\let\folio=0%
  1404. \def\rawbackslashxx{\indexbackslash}%
  1405. %
  1406. % Now process the index-string once, with all font commands turned off,
  1407. % to get the string to sort the index by.
  1408. {\indexnofonts
  1409. \xdef\temp1{#2 #3}%
  1410. }%
  1411. % Now produce the complete index entry.  We process the index-string again,
  1412. % this time with font commands expanded, to get what to print in the index.
  1413. \edef\temp{%
  1414. \write \csname#1indfile\endcsname{%
  1415. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1416. \temp }%
  1417. }\penalty\count10}}
  1418.  
  1419. % The index entry written in the file actually looks like
  1420. %  \entry {sortstring}{page}{topic}
  1421. % or
  1422. %  \entry {sortstring}{page}{topic}{subtopic}
  1423. % The texindex program reads in these files and writes files
  1424. % containing these kinds of lines:
  1425. %  \initial {c}
  1426. %     before the first topic whose initial is c
  1427. %  \entry {topic}{pagelist}
  1428. %     for a topic that is used without subtopics
  1429. %  \primary {topic}
  1430. %     for the beginning of a topic that is used with subtopics
  1431. %  \secondary {subtopic}{pagelist}
  1432. %     for each subtopic.
  1433.  
  1434. % Define the user-accessible indexing commands 
  1435. % @findex, @vindex, @kindex, @cindex.
  1436.  
  1437. \def\findex {\fnindex}
  1438. \def\kindex {\kyindex}
  1439. \def\cindex {\cpindex}
  1440. \def\vindex {\vrindex}
  1441. \def\tindex {\tpindex}
  1442. \def\pindex {\pgindex}
  1443.  
  1444. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1445. {\obeylines %
  1446. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1447. \dosubind{cp}{#2}{#1}}}
  1448.  
  1449. % Define the macros used in formatting output of the sorted index material.
  1450.  
  1451. % This is what you call to cause a particular index to get printed.
  1452. % Write
  1453. % @unnumbered Function Index
  1454. % @printindex fn
  1455.  
  1456. \def\printindex{\parsearg\doprintindex}
  1457.  
  1458. \def\doprintindex#1{%
  1459.   \tex
  1460.   \dobreak \chapheadingskip {10000}
  1461.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1462.   \catcode`\$=\other\catcode`\_=\other
  1463.   \catcode`\~=\other
  1464.   %
  1465.   % The following don't help, since the chars were translated
  1466.   % when the raw index was written, and their fonts were discarded
  1467.   % due to \indexnofonts.
  1468.   %\catcode`\"=\active
  1469.   %\catcode`\^=\active
  1470.   %\catcode`\_=\active
  1471.   %\catcode`\|=\active
  1472.   %\catcode`\<=\active
  1473.   %\catcode`\>=\active
  1474.   % %
  1475.   \def\indexbackslash{\rawbackslashxx}
  1476.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1477.   \begindoublecolumns
  1478.   %
  1479.   % See if the index file exists and is nonempty.
  1480.   \openin 1 \jobname.#1s
  1481.   \ifeof 1 
  1482.     % \enddoublecolumns gets confused if there is no text in the index,
  1483.     % and it loses the chapter title and the aux file entries for the
  1484.     % index.  The easiest way to prevent this problem is to make sure
  1485.     % there is some text.
  1486.     (Index is nonexistent)
  1487.     \else
  1488.     %
  1489.     % If the index file exists but is empty, then \openin leaves \ifeof
  1490.     % false.  We have to make TeX try to read something from the file, so
  1491.     % it can discover if there is anything in it.
  1492.     \read 1 to \temp
  1493.     \ifeof 1
  1494.       (Index is empty)
  1495.     \else
  1496.       \input \jobname.#1s
  1497.     \fi
  1498.   \fi
  1499.   \closein 1
  1500.   \enddoublecolumns
  1501.   \Etex
  1502. }
  1503.  
  1504. % These macros are used by the sorted index file itself.
  1505. % Change them to control the appearance of the index.
  1506.  
  1507. % Same as \bigskipamount except no shrink.
  1508. % \balancecolumns gets confused if there is any shrink.
  1509. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1510.  
  1511. \def\initial #1{%
  1512. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1513. \ifdim\lastskip<\initialskipamount
  1514. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1515. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1516.  
  1517. \def\entry #1#2{\begingroup
  1518.   \parfillskip=0in \parskip=0in \parindent=0in
  1519.   %
  1520.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1521.   \finalhyphendemerits = 0
  1522.   %
  1523.   % \hangindent is only relevant when the entry text and page number
  1524.   % don't both fit on one line.  In that case, bob suggests starting the
  1525.   % dots pretty far over on the line.  Unfortunately, a large
  1526.   % indentation looks wrong when the entry text itself is broken across
  1527.   % lines.  So we use a small indentation and put up with long leaders.
  1528.   % 
  1529.   % \hangafter is reset to 1 (which is the value we want) at the start
  1530.   % of each paragraph, so we need not do anything with that.
  1531.   \hangindent=2em
  1532.   %
  1533.   % When the entry text needs to be broken, just fill out the first line
  1534.   % with blank space.
  1535.   \rightskip = 0pt plus1fil
  1536.   %
  1537.   % Start a ``paragraph'' for the index entry so the line breaking
  1538.   % parameters we've set above will have an effect.
  1539.   \noindent
  1540.   %
  1541.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1542.   #1%
  1543.   %
  1544.   % If we must, put the page number on a line of its own, and fill out
  1545.   % this line with blank space.  (The \hfil is overwhelmed with the
  1546.   % fill leaders glue in \indexdotfill if the page number does fit.)
  1547.   \hfil\penalty50
  1548.   \null\nobreak\indexdotfill % Have leaders before the page number.
  1549.   %
  1550.   % The `\ ' here is removed by the implicit \unskip that TeX does as
  1551.   % part of (the primitive) \par.  Without it, a spurious underfull
  1552.   % \hbox ensues.
  1553.   \ #2% The page number ends the paragraph.
  1554.   \par
  1555. \endgroup}
  1556.  
  1557. % Like \dotfill except takes at least 1 em.
  1558. \def\indexdotfill{\cleaders
  1559.   \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill}
  1560.  
  1561. \def\primary #1{\line{#1\hfil}}
  1562.  
  1563. \newskip\secondaryindent \secondaryindent=0.5cm
  1564.  
  1565. \def\secondary #1#2{
  1566. {\parfillskip=0in \parskip=0in
  1567. \hangindent =1in \hangafter=1
  1568. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1569. }}
  1570.  
  1571. %% Define two-column mode, which is used in indexes.
  1572. %% Adapted from the TeXBook, page 416
  1573. \catcode `\@=11
  1574.  
  1575. \newbox\partialpage
  1576.  
  1577. \newdimen\doublecolumnhsize  \doublecolumnhsize = 3.11in
  1578. \newdimen\doublecolumnvsize  \doublecolumnvsize = 19.1in
  1579. \newdimen\availdimen@
  1580.  
  1581. \def\begindoublecolumns{\begingroup
  1582.   \output={\global\setbox\partialpage=
  1583.     \vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject
  1584.   \output={\doublecolumnout}%
  1585.   \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize}
  1586. \def\enddoublecolumns{\output={\balancecolumns}\eject
  1587.   \endgroup \pagegoal=\vsize}
  1588.  
  1589. \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1590.   \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1591.   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1592.   \onepageout\pagesofar \unvbox255 \penalty\outputpenalty}
  1593. \def\pagesofar{\unvbox\partialpage %
  1594.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1595. %          changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986)
  1596.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1597. \def\balancecolumns{%
  1598. % Unset the glue.
  1599.   \setbox255=\vbox{\unvbox255}
  1600.   \dimen@=\ht255
  1601.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1602.   \divide\dimen@ by2
  1603.   \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage
  1604. % If the remaining data is too big for one page,
  1605. % output one page normally, then work with what remains.
  1606.   \ifdim \dimen@>\availdimen@
  1607.    {
  1608.      \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1609.      \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage
  1610.      \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  1611.      \onepageout\pagesofar
  1612.    }
  1613. % Recompute size of what remains, in case we just output some of it.
  1614.   \dimen@=\ht255
  1615.   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1616.   \divide\dimen@ by2
  1617.   \fi
  1618.   \setbox0=\vbox{\unvbox255}
  1619.   \splittopskip=\topskip
  1620.   {\vbadness=10000 \loop \global\setbox3=\copy0
  1621.     \global\setbox1=\vsplit3 to\dimen@
  1622.     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  1623.   \setbox0=\vbox to\dimen@{\unvbox1}  \setbox2=\vbox to\dimen@{\unvbox3}
  1624.   \pagesofar}
  1625.  
  1626. \catcode `\@=\other
  1627. \message{sectioning,}
  1628. % Define chapters, sections, etc.
  1629.  
  1630. \newcount \chapno
  1631. \newcount \secno        \secno=0
  1632. \newcount \subsecno     \subsecno=0
  1633. \newcount \subsubsecno  \subsubsecno=0
  1634.  
  1635. % This counter is funny since it counts through charcodes of letters A, B, ...
  1636. \newcount \appendixno  \appendixno = `\@
  1637. \def\appendixletter{\char\the\appendixno}
  1638.  
  1639. \newwrite \contentsfile
  1640. % This is called from \setfilename.
  1641. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1642.  
  1643. % Each @chapter defines this as the name of the chapter.
  1644. % page headings and footings can use it.  @section does likewise
  1645.  
  1646. \def\thischapter{} \def\thissection{}
  1647. \def\seccheck#1{\if \pageno<0 %
  1648. \errmessage{@#1 not allowed after generating table of contents}\fi
  1649. %
  1650. }
  1651.  
  1652. \def\chapternofonts{%
  1653. \let\rawbackslash=\relax%
  1654. \let\frenchspacing=\relax%
  1655. \def\result{\realbackslash result}
  1656. \def\equiv{\realbackslash equiv}
  1657. \def\expansion{\realbackslash expansion}
  1658. \def\print{\realbackslash print}
  1659. \def\TeX{\realbackslash TeX}
  1660. \def\dots{\realbackslash dots}
  1661. \def\copyright{\realbackslash copyright}
  1662. \def\tt{\realbackslash tt}
  1663. \def\bf{\realbackslash bf }
  1664. \def\w{\realbackslash w}
  1665. \def\less{\realbackslash less}
  1666. \def\gtr{\realbackslash gtr}
  1667. \def\hat{\realbackslash hat}
  1668. \def\char{\realbackslash char}
  1669. \def\tclose##1{\realbackslash tclose {##1}}
  1670. \def\code##1{\realbackslash code {##1}}
  1671. \def\samp##1{\realbackslash samp {##1}}
  1672. \def\r##1{\realbackslash r {##1}}
  1673. \def\b##1{\realbackslash b {##1}}
  1674. \def\key##1{\realbackslash key {##1}}
  1675. \def\file##1{\realbackslash file {##1}}
  1676. \def\kbd##1{\realbackslash kbd {##1}}
  1677. % These are redefined because @smartitalic wouldn't work inside xdef.
  1678. \def\i##1{\realbackslash i {##1}}
  1679. \def\cite##1{\realbackslash cite {##1}}
  1680. \def\var##1{\realbackslash var {##1}}
  1681. \def\emph##1{\realbackslash emph {##1}}
  1682. \def\dfn##1{\realbackslash dfn {##1}}
  1683. }
  1684.  
  1685. \def\thischaptername{No Chapter Title}
  1686. \outer\def\chapter{\parsearg\chapterzzz}
  1687. \def\chapterzzz #1{\seccheck{chapter}%
  1688. \secno=0 \subsecno=0 \subsubsecno=0
  1689. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1690. \chapmacro {#1}{\the\chapno}%
  1691. \gdef\thissection{#1}%
  1692. \gdef\thischaptername{#1}%
  1693. % We don't substitute the actual chapter name into \thischapter
  1694. % because we don't want its macros evaluated now.
  1695. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}%
  1696. {\chapternofonts%
  1697. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1698. \escapechar=`\\%
  1699. \write \contentsfile \temp  %
  1700. \donoderef %
  1701. \global\let\section = \numberedsec
  1702. \global\let\subsection = \numberedsubsec
  1703. \global\let\subsubsection = \numberedsubsubsec
  1704. }}
  1705.  
  1706. \outer\def\appendix{\parsearg\appendixzzz}
  1707. \def\appendixzzz #1{\seccheck{appendix}%
  1708. \secno=0 \subsecno=0 \subsubsecno=0
  1709. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1710. \chapmacro {#1}{Appendix \appendixletter}%
  1711. \gdef\thissection{#1}%
  1712. \gdef\thischaptername{#1}%
  1713. \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}%
  1714. {\chapternofonts%
  1715. \edef\temp{{\realbackslash chapentry 
  1716.   {#1}{Appendix \appendixletter}{\noexpand\folio}}}%
  1717. \escapechar=`\\%
  1718. \write \contentsfile \temp  %
  1719. \appendixnoderef %
  1720. \global\let\section = \appendixsec
  1721. \global\let\subsection = \appendixsubsec
  1722. \global\let\subsubsection = \appendixsubsubsec
  1723. }}
  1724.  
  1725. \outer\def\top{\parsearg\unnumberedzzz}
  1726. \outer\def\unnumbered{\parsearg\unnumberedzzz}
  1727. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1728. \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)}
  1729. \unnumbchapmacro {#1}%
  1730. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1731. {\chapternofonts%
  1732. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1733. \escapechar=`\\%
  1734. \write \contentsfile \temp  %
  1735. \unnumbnoderef %
  1736. \global\let\section = \unnumberedsec
  1737. \global\let\subsection = \unnumberedsubsec
  1738. \global\let\subsubsection = \unnumberedsubsubsec
  1739. }}
  1740.  
  1741. \outer\def\numberedsec{\parsearg\seczzz}
  1742. \def\seczzz #1{\seccheck{section}%
  1743. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1744. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1745. {\chapternofonts%
  1746. \edef\temp{{\realbackslash secentry %
  1747. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1748. \escapechar=`\\%
  1749. \write \contentsfile \temp %
  1750. \donoderef %
  1751. \penalty 10000 %
  1752. }}
  1753.  
  1754. \outer\def\appendixsection{\parsearg\appendixsectionzzz}
  1755. \outer\def\appendixsec{\parsearg\appendixsectionzzz}
  1756. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1757. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1758. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1759. {\chapternofonts%
  1760. \edef\temp{{\realbackslash secentry %
  1761. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1762. \escapechar=`\\%
  1763. \write \contentsfile \temp %
  1764. \appendixnoderef %
  1765. \penalty 10000 %
  1766. }}
  1767.  
  1768. \outer\def\unnumberedsec{\parsearg\unnumberedseczzz}
  1769. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1770. \plainsecheading {#1}\gdef\thissection{#1}%
  1771. {\chapternofonts%
  1772. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1773. \escapechar=`\\%
  1774. \write \contentsfile \temp %
  1775. \unnumbnoderef %
  1776. \penalty 10000 %
  1777. }}
  1778.  
  1779. \outer\def\numberedsubsec{\parsearg\numberedsubseczzz}
  1780. \def\numberedsubseczzz #1{\seccheck{subsection}%
  1781. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1782. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1783. {\chapternofonts%
  1784. \edef\temp{{\realbackslash subsecentry %
  1785. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1786. \escapechar=`\\%
  1787. \write \contentsfile \temp %
  1788. \donoderef %
  1789. \penalty 10000 %
  1790. }}
  1791.  
  1792. \outer\def\appendixsubsec{\parsearg\appendixsubseczzz}
  1793. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1794. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1795. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1796. {\chapternofonts%
  1797. \edef\temp{{\realbackslash subsecentry %
  1798. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1799. \escapechar=`\\%
  1800. \write \contentsfile \temp %
  1801. \appendixnoderef %
  1802. \penalty 10000 %
  1803. }}
  1804.  
  1805. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1806. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1807. \plainsecheading {#1}\gdef\thissection{#1}%
  1808. {\chapternofonts%
  1809. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1810. \escapechar=`\\%
  1811. \write \contentsfile \temp %
  1812. \unnumbnoderef %
  1813. \penalty 10000 %
  1814. }}
  1815.  
  1816. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz}
  1817. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  1818. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1819. \subsubsecheading {#1}
  1820.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1821. {\chapternofonts%
  1822. \edef\temp{{\realbackslash subsubsecentry %
  1823.   {#1}
  1824.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  1825.   {\noexpand\folio}}}%
  1826. \escapechar=`\\%
  1827. \write \contentsfile \temp %
  1828. \donoderef %
  1829. \penalty 10000 %
  1830. }}
  1831.  
  1832. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1833. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1834. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1835. \subsubsecheading {#1}
  1836.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1837. {\chapternofonts%
  1838. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1839.   {\appendixletter}
  1840.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  1841. \escapechar=`\\%
  1842. \write \contentsfile \temp %
  1843. \appendixnoderef %
  1844. \penalty 10000 %
  1845. }}
  1846.  
  1847. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1848. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  1849. \plainsecheading {#1}\gdef\thissection{#1}%
  1850. {\chapternofonts%
  1851. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  1852. \escapechar=`\\%
  1853. \write \contentsfile \temp %
  1854. \unnumbnoderef %
  1855. \penalty 10000 %
  1856. }}
  1857.  
  1858. % These are variants which are not "outer", so they can appear in @ifinfo.
  1859. % Actually, they should now be obsolete; ordinary section commands should work.
  1860. \def\infotop{\parsearg\unnumberedzzz}
  1861. \def\infounnumbered{\parsearg\unnumberedzzz}
  1862. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  1863. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  1864. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  1865.  
  1866. \def\infoappendix{\parsearg\appendixzzz}
  1867. \def\infoappendixsec{\parsearg\appendixseczzz}
  1868. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  1869. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  1870.  
  1871. \def\infochapter{\parsearg\chapterzzz}
  1872. \def\infosection{\parsearg\sectionzzz}
  1873. \def\infosubsection{\parsearg\subsectionzzz}
  1874. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  1875.  
  1876. % These macros control what the section commands do, according
  1877. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  1878. % Define them by default for a numbered chapter.
  1879. \global\let\section = \numberedsec
  1880. \global\let\subsection = \numberedsubsec
  1881. \global\let\subsubsection = \numberedsubsubsec
  1882.  
  1883. % Define @majorheading, @heading and @subheading
  1884.  
  1885. % NOTE on use of \vbox for chapter headings, section headings, and
  1886. % such:
  1887. %    1) We use \vbox rather than the earlier \line to permit
  1888. %       overlong headings to fold.
  1889. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  1890. %       heading is obnoxious; this forbids it.
  1891. %       3) Likewise, headings look best if no \parindent is used, and
  1892. %          if justification is not attempted.  Hence \raggedright.
  1893.  
  1894.  
  1895. \def\majorheading{\parsearg\majorheadingzzz}
  1896. \def\majorheadingzzz #1{%
  1897. {\advance\chapheadingskip by 10pt \chapbreak }%
  1898. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1899.                   \parindent=0pt\raggedright
  1900.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1901.  
  1902. \def\chapheading{\parsearg\chapheadingzzz}
  1903. \def\chapheadingzzz #1{\chapbreak %
  1904. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1905.                   \parindent=0pt\raggedright
  1906.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  1907.  
  1908. \def\heading{\parsearg\secheadingi}
  1909.  
  1910. \def\subheading{\parsearg\subsecheadingi}
  1911.  
  1912. \def\subsubheading{\parsearg\subsubsecheadingi}
  1913.  
  1914. % These macros generate a chapter, section, etc. heading only
  1915. % (including whitespace, linebreaking, etc. around it),
  1916. % given all the information in convenient, parsed form.
  1917.  
  1918. %%% Args are the skip and penalty (usually negative)
  1919. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  1920.  
  1921. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  1922.  
  1923. %%% Define plain chapter starts, and page on/off switching for it
  1924. % Parameter controlling skip before chapter headings (if needed)
  1925.  
  1926. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  1927.  
  1928. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  1929. \def\chappager{\par\vfill\supereject}
  1930. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  1931.  
  1932. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  1933.  
  1934. \def\CHAPPAGoff{
  1935. \global\let\pchapsepmacro=\chapbreak
  1936. \global\let\pagealignmacro=\chappager}
  1937.  
  1938. \def\CHAPPAGon{
  1939. \global\let\pchapsepmacro=\chappager
  1940. \global\let\pagealignmacro=\chappager
  1941. \global\def\HEADINGSon{\HEADINGSsingle}}
  1942.  
  1943. \def\CHAPPAGodd{
  1944. \global\let\pchapsepmacro=\chapoddpage
  1945. \global\let\pagealignmacro=\chapoddpage
  1946. \global\def\HEADINGSon{\HEADINGSdouble}}
  1947.  
  1948. \CHAPPAGon
  1949.  
  1950. \def\CHAPFplain{
  1951. \global\let\chapmacro=\chfplain
  1952. \global\let\unnumbchapmacro=\unnchfplain}
  1953.  
  1954. \def\chfplain #1#2{%
  1955.   \pchapsepmacro
  1956.   {%
  1957.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1958.                      \parindent=0pt\raggedright
  1959.                      \rm #2\enspace #1}%
  1960.   }%
  1961.   \bigskip
  1962.   \penalty5000
  1963. }
  1964.  
  1965. \def\unnchfplain #1{%
  1966. \pchapsepmacro %
  1967. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1968.                   \parindent=0pt\raggedright
  1969.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1970. }
  1971. \CHAPFplain % The default
  1972.  
  1973. \def\unnchfopen #1{%
  1974. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  1975.                        \parindent=0pt\raggedright
  1976.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  1977. }
  1978.  
  1979. \def\chfopen #1#2{\chapoddpage {\chapfonts
  1980. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  1981. \par\penalty 5000 %
  1982. }
  1983.  
  1984. \def\CHAPFopen{
  1985. \global\let\chapmacro=\chfopen
  1986. \global\let\unnumbchapmacro=\unnchfopen}
  1987.  
  1988. % Parameter controlling skip before section headings.
  1989.  
  1990. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  1991. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  1992.  
  1993. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  1994. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  1995.  
  1996. % @paragraphindent  is defined for the Info formatting commands only.
  1997. \let\paragraphindent=\comment
  1998.  
  1999. % Section fonts are the base font at magstep2, which produces
  2000. % a size a bit more than 14 points in the default situation.    
  2001.  
  2002. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  2003. \def\plainsecheading #1{\secheadingi {#1}}
  2004. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  2005. \secheadingbreak}%
  2006. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2007.                  \parindent=0pt\raggedright
  2008.                  \rm #1\hfill}}%
  2009. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2010.  
  2011.  
  2012. % Subsection fonts are the base font at magstep1, 
  2013. % which produces a size of 12 points.
  2014.  
  2015. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  2016. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2017. \subsecheadingbreak}%
  2018. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2019.                      \parindent=0pt\raggedright
  2020.                      \rm #1\hfill}}%
  2021. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2022.  
  2023. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  2024.                   % Perhaps make sssec fonts scaled
  2025.                   % magstep half
  2026. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  2027. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2028. \subsecheadingbreak}%
  2029. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2030.                        \parindent=0pt\raggedright
  2031.                        \rm #1\hfill}}%
  2032. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  2033.  
  2034.  
  2035. \message{toc printing,}
  2036.  
  2037. % Finish up the main text and prepare to read what we've written
  2038. % to \contentsfile.
  2039.  
  2040. \newskip\contentsrightmargin \contentsrightmargin=1in
  2041. \def\startcontents#1{%
  2042.    \pagealignmacro
  2043.    \immediate\closeout \contentsfile
  2044.    \ifnum \pageno>0
  2045.       \pageno = -1        % Request roman numbered pages.
  2046.    \fi
  2047.    % Don't need to put `Contents' or `Short Contents' in the headline. 
  2048.    % It is abundantly clear what they are.
  2049.    \unnumbchapmacro{#1}\def\thischapter{}%
  2050.    \begingroup           % Set up to handle contents files properly.
  2051.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  2052.       \raggedbottom             % Worry more about breakpoints than the bottom.
  2053.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  2054. }
  2055.  
  2056.   
  2057. % Normal (long) toc.
  2058. \outer\def\contents{%
  2059.    \startcontents{Table of Contents}%
  2060.       \input \jobname.toc
  2061.    \endgroup
  2062.    \vfill \eject
  2063. }
  2064.  
  2065. % And just the chapters.
  2066. \outer\def\summarycontents{%
  2067.    \startcontents{Short Contents}%
  2068.       %
  2069.       \let\chapentry = \shortchapentry
  2070.       \let\unnumbchapentry = \shortunnumberedentry
  2071.       % We want a true roman here for the page numbers.
  2072.       \secfonts
  2073.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  2074.       \rm
  2075.       \advance\baselineskip by 1pt % Open it up a little.
  2076.       \def\secentry ##1##2##3##4{}
  2077.       \def\unnumbsecentry ##1##2{}
  2078.       \def\subsecentry ##1##2##3##4##5{}
  2079.       \def\unnumbsubsecentry ##1##2{}
  2080.       \def\subsubsecentry ##1##2##3##4##5##6{}
  2081.       \def\unnumbsubsubsecentry ##1##2{}
  2082.       \input \jobname.toc
  2083.    \endgroup
  2084.    \vfill \eject
  2085. }
  2086. \let\shortcontents = \summarycontents
  2087.  
  2088. % These macros generate individual entries in the table of contents.
  2089. % The first argument is the chapter or section name.
  2090. % The last argument is the page number.
  2091. % The arguments in between are the chapter number, section number, ...
  2092.  
  2093. % Chapter-level things, for both the long and short contents.
  2094. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  2095.  
  2096. % See comments in \dochapentry re vbox and related settings
  2097. \def\shortchapentry#1#2#3{%
  2098.    \vbox{\hyphenpenalty=10000\tolerance=5000
  2099.     \parindent=0pt\strut\raggedright
  2100.     {\shortchaplabel{#2}\labelspace #1}\dotfill\doshortpageno{#3}}%
  2101. }
  2102.  
  2103. % Typeset the label for a chapter or appendix for the short contents.
  2104. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  2105. % We could simplify the code here by writing out an \appendixentry
  2106. % command in the toc file for appendices, instead of using \chapentry
  2107. % for both, but it doesn't seem worth it.
  2108. \setbox0 = \hbox{\shortcontrm Appendix }
  2109. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  2110.  
  2111. \def\shortchaplabel#1{%
  2112.   % We typeset #1 in a box of constant width, regardless of the text of
  2113.   % #1, so the chapter titles will come out aligned.
  2114.   \setbox0 = \hbox{#1}%
  2115.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  2116.   %
  2117.   % This space should be plenty, since a single number is .5em, and the
  2118.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  2119.   % (This space doesn't include the extra space that gets added after
  2120.   % the label; that gets put in in \shortchapentry above.)
  2121.   \advance\dimen0 by 1.1em
  2122.   \hbox to \dimen0{#1\hfil}%
  2123. }
  2124.  
  2125. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  2126. \def\shortunnumberedentry#1#2{%
  2127.    \vbox{\hyphenpenalty=10000\tolerance=5000
  2128.     \parindent=0pt\strut\raggedright
  2129.     #1\dotfill\doshortpageno{#2}}%
  2130. }
  2131.  
  2132. % Sections.
  2133. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  2134. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  2135.  
  2136. % Subsections.
  2137. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  2138. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  2139.  
  2140. % And subsubsections.
  2141. \def\subsubsecentry#1#2#3#4#5#6{%
  2142.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  2143. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  2144.  
  2145.  
  2146. % This parameter controls the indentation of the various levels.
  2147. \newdimen\tocindent \tocindent = 3pc
  2148.  
  2149. % Now for the actual typesetting. In all these, #1 is the text and #2 is the 
  2150. % page number.
  2151. %
  2152. % If the toc has to be broken over pages, we would want to be at chapters 
  2153. % if at all possible; hence the \penalty.
  2154. \def\dochapentry#1#2{%
  2155.    \penalty-300 \vskip\baselineskip
  2156.    % This \vbox (and similar ones in dosecentry etc.) used to be a
  2157.    % \line; changed to permit linebreaks for long headings.  See
  2158.    % comments above \majorheading.  Here we also use \strut to
  2159.    % keep the top end of the vbox from jamming up against the previous
  2160.    % entry in the table of contents.
  2161.    \vbox{\chapentryfonts
  2162.      \hyphenpenalty=10000\tolerance=5000 % this line and next introduced
  2163.      \parindent=0pt\strut\raggedright    % with \line -> \vbox change
  2164.      #1\dotfill
  2165.      \dopageno{#2}}%
  2166.    \nobreak\vskip .25\baselineskip
  2167. }
  2168.  
  2169. \def\dosecentry#1#2{%
  2170.    \vbox{\secentryfonts \leftskip=\tocindent
  2171.     \hyphenpenalty=10000\tolerance=5000
  2172.     \parindent=0pt\strut\raggedright #1\dotfill
  2173.     \dopageno{#2}}%
  2174. }
  2175.  
  2176. \def\dosubsecentry#1#2{%
  2177.    \vbox{\subsecentryfonts \leftskip=2\tocindent
  2178.     \hyphenpenalty=10000\tolerance=5000
  2179.     \parindent=0pt\strut\raggedright #1\dotfill
  2180.     \dopageno{#2}}%
  2181. }
  2182.  
  2183. \def\dosubsubsecentry#1#2{%
  2184.    \vbox{\subsubsecentryfonts \leftskip=3\tocindent
  2185.     \hyphenpenalty=10000\tolerance=5000
  2186.     \parindent=0pt\strut\raggedright #1\dotfill
  2187.     \dopageno{#2}}%
  2188. }
  2189.  
  2190. % Space between chapter (or whatever) number and the title.
  2191. \def\labelspace{\hskip1em \relax}
  2192.  
  2193. \def\dopageno#1{{\rm #1}}
  2194. \def\doshortpageno#1{{\rm #1}}
  2195.  
  2196. \def\chapentryfonts{\secfonts \rm}
  2197. \def\secentryfonts{\textfonts}
  2198. \let\subsecentryfonts = \textfonts
  2199. \let\subsubsecentryfonts = \textfonts
  2200.  
  2201.  
  2202. \message{environments,}
  2203.  
  2204. % Since these characters are used in examples, it should be an even number of 
  2205. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  2206. % Furthermore, these definitions must come after we define our fonts.
  2207. \newbox\dblarrowbox    \newbox\longdblarrowbox
  2208. \newbox\pushcharbox    \newbox\bullbox
  2209. \newbox\equivbox       \newbox\errorbox
  2210.  
  2211. \let\ptexequiv = \equiv
  2212.  
  2213. %{\tentt
  2214. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  2215. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  2216. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  2217. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2218. % Adapted from the manmac format (p.420 of TeXbook)
  2219. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2220. %                                      depth .1ex\hfil}
  2221. %}
  2222.  
  2223. \def\point{$\star$}
  2224.  
  2225. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  2226. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  2227. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  2228.  
  2229. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  2230.  
  2231. % Adapted from the TeXbook's \boxit.
  2232. {\tentt \global\dimen0 = 3em}% Width of the box.
  2233. \dimen2 = .55pt % Thickness of rules
  2234. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  2235. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  2236.  
  2237. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  2238.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  2239.    \advance\hsize by -2\dimen2 % Rules.
  2240.    \vbox{
  2241.       \hrule height\dimen2
  2242.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  2243.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  2244.          \kern3pt\vrule width\dimen2}% Space to right.
  2245.       \hrule height\dimen2}
  2246.     \hfil}
  2247.  
  2248. % The @error{} command.
  2249. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  2250.  
  2251. % @tex ... @end tex    escapes into raw Tex temporarily.
  2252. % One exception: @ is still an escape character, so that @end tex works.
  2253. % But \@ or @@ will get a plain tex @ character.
  2254.  
  2255. \def\tex{\begingroup
  2256. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  2257. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  2258. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  2259. \catcode `\%=14
  2260. \catcode 43=12
  2261. \catcode`\"=12
  2262. \catcode`\==12
  2263. \catcode`\|=12
  2264. \catcode`\<=12
  2265. \catcode`\>=12
  2266. \escapechar=`\\
  2267. %
  2268. \let\{=\ptexlbrace
  2269. \let\}=\ptexrbrace
  2270. \let\.=\ptexdot
  2271. \let\*=\ptexstar
  2272. \let\dots=\ptexdots
  2273. \def\@{@}%
  2274. \let\bullet=\ptexbullet
  2275. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  2276. \let\L=\ptexL
  2277. %
  2278. \let\Etex=\endgroup}
  2279.  
  2280. % Define @lisp ... @endlisp.
  2281. % @lisp does a \begingroup so it can rebind things,
  2282. % including the definition of @endlisp (which normally is erroneous).
  2283.  
  2284. % Amount to narrow the margins by for @lisp.
  2285. \newskip\lispnarrowing \lispnarrowing=0.4in
  2286.  
  2287. % This is the definition that ^M gets inside @lisp
  2288. % phr: changed space to \null, to avoid overfull hbox problems.
  2289. {\obeyspaces%
  2290. \gdef\lisppar{\null\endgraf}}
  2291.  
  2292. % Cause \obeyspaces to make each Space cause a word-separation
  2293. % rather than the default which is that it acts punctuation.
  2294. % This is because space in tt font looks funny.
  2295. {\obeyspaces %
  2296. \gdef\sepspaces{\def {\ }}}
  2297.  
  2298. % This space is always present above and below environments.
  2299. \newskip\envskipamount \envskipamount = 0pt
  2300.  
  2301. % Make spacing and below environment symmetrical.
  2302. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  2303. \endgraf \ifdim\lastskip<\envskipamount
  2304. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  2305.  
  2306. \let\afterenvbreak = \aboveenvbreak
  2307.  
  2308. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  2309. \let\nonarrowing=\relax
  2310.  
  2311. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2312. % \cartouche: draw rectangle w/rounded corners around argument
  2313. \font\circle=lcircle10
  2314. \newdimen\circthick
  2315. \newdimen\cartouter\newdimen\cartinner
  2316. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  2317. \circthick=\fontdimen8\circle
  2318. %
  2319. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  2320. \def\ctr{{\hskip 6pt\circle\char'010}}
  2321. \def\cbl{{\circle\char'012\hskip -6pt}}
  2322. \def\cbr{{\hskip 6pt\circle\char'011}}
  2323. \def\carttop{\hbox to \cartouter{\hskip\lskip
  2324.     \ctl\leaders\hrule height\circthick\hfil\ctr
  2325.     \hskip\rskip}}
  2326. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  2327.     \cbl\leaders\hrule height\circthick\hfil\cbr
  2328.     \hskip\rskip}}
  2329. %
  2330. \newskip\lskip\newskip\rskip
  2331.  
  2332. \long\def\cartouche{%
  2333. \begingroup
  2334.     \lskip=\leftskip \rskip=\rightskip
  2335.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  2336.     \cartinner=\hsize \advance\cartinner by-\lskip 
  2337.                \advance\cartinner by-\rskip
  2338.     \cartouter=\hsize
  2339.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  2340. %                     side, and for 6pt waste from
  2341. %                     each corner char
  2342.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  2343.     % Flag to tell @lisp, etc., not to narrow margin.
  2344.     \let\nonarrowing=\comment
  2345.     \vbox\bgroup
  2346.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  2347.         \carttop
  2348.         \hbox\bgroup
  2349.             \hskip\lskip
  2350.             \vrule\kern3pt
  2351.             \vbox\bgroup
  2352.                 \hsize=\cartinner
  2353.                 \kern3pt
  2354.                 \begingroup
  2355.                     \baselineskip=\normbskip
  2356.                     \lineskip=\normlskip
  2357.                     \parskip=\normpskip
  2358.                     \vskip -\parskip
  2359. \def\Ecartouche{%
  2360.                 \endgroup
  2361.                 \kern3pt
  2362.             \egroup
  2363.             \kern3pt\vrule
  2364.             \hskip\rskip
  2365.         \egroup
  2366.         \cartbot
  2367.     \egroup
  2368. \endgroup
  2369. }}    
  2370.  
  2371. \def\lisp{\aboveenvbreak
  2372. \begingroup\inENV % This group ends at the end of the @lisp body
  2373. \hfuzz=12truept % Don't be fussy
  2374. % Make spaces be word-separators rather than space tokens.
  2375. \sepspaces %
  2376. % Single space lines
  2377. \singlespace %
  2378. % The following causes blank lines not to be ignored
  2379. % by adding a space to the end of each line.
  2380. \let\par=\lisppar
  2381. \def\Elisp{\endgroup\afterenvbreak}%
  2382. \parskip=0pt
  2383. % @cartouche defines \nonarrowing to inhibit narrowing
  2384. % at next level down.
  2385. \ifx\nonarrowing\relax
  2386. \advance \leftskip by \lispnarrowing
  2387. \exdentamount=\lispnarrowing
  2388. \let\exdent=\nofillexdent
  2389. \let\nonarrowing=\relax
  2390. \fi
  2391. \parindent=0pt
  2392. \obeyspaces \obeylines \tt \rawbackslash
  2393. \def\next##1{}\next}
  2394.  
  2395.  
  2396. \let\example=\lisp
  2397. \def\Eexample{\Elisp}
  2398.  
  2399. \let\smallexample=\lisp
  2400. \def\Esmallexample{\Elisp}
  2401.  
  2402. % Macro for 9 pt. examples, necessary to print with 5" lines.
  2403. % From Pavel@xerox.  This is not really used unless the
  2404. % @smallbook command is given.
  2405.  
  2406. \def\smalllispx{\aboveenvbreak\begingroup\inENV
  2407. %            This group ends at the end of the @lisp body
  2408. \hfuzz=12truept % Don't be fussy
  2409. % Make spaces be word-separators rather than space tokens.
  2410. \sepspaces %
  2411. % Single space lines
  2412. \singlespace %
  2413. % The following causes blank lines not to be ignored
  2414. % by adding a space to the end of each line.
  2415. \let\par=\lisppar
  2416. \def\Esmalllisp{\endgroup\afterenvbreak}%
  2417. %%%% Smaller baseline skip for small examples.
  2418. \baselineskip 10pt
  2419. \parskip=0pt
  2420. % @cartouche defines \nonarrowing to inhibit narrowing
  2421. % at next level down.
  2422. \ifx\nonarrowing\relax
  2423. \advance \leftskip by \lispnarrowing
  2424. \exdentamount=\lispnarrowing
  2425. \let\exdent=\nofillexdent
  2426. \let\nonarrowing=\relax
  2427. \fi
  2428. \parindent=0pt
  2429. \obeyspaces \obeylines \ninett \indexfonts \rawbackslash
  2430. \def\next##1{}\next}
  2431.  
  2432. % This is @display; same as @lisp except use roman font.
  2433.  
  2434. \def\display{\begingroup\inENV %This group ends at the end of the @display body
  2435. \aboveenvbreak
  2436. % Make spaces be word-separators rather than space tokens.
  2437. \sepspaces %
  2438. % Single space lines
  2439. \singlespace %
  2440. % The following causes blank lines not to be ignored
  2441. % by adding a space to the end of each line.
  2442. \let\par=\lisppar
  2443. \def\Edisplay{\endgroup\afterenvbreak}%
  2444. \parskip=0pt
  2445. % @cartouche defines \nonarrowing to inhibit narrowing
  2446. % at next level down.
  2447. \ifx\nonarrowing\relax
  2448. \advance \leftskip by \lispnarrowing
  2449. \exdentamount=\lispnarrowing
  2450. \let\exdent=\nofillexdent
  2451. \let\nonarrowing=\relax
  2452. \fi
  2453. \parindent=0pt
  2454. \obeyspaces \obeylines
  2455. \def\next##1{}\next}
  2456.  
  2457. % This is @format; same as @lisp except use roman font and don't narrow margins
  2458.  
  2459. \def\format{\begingroup\inENV %This group ends at the end of the @format body
  2460. \aboveenvbreak
  2461. % Make spaces be word-separators rather than space tokens.
  2462. \sepspaces %
  2463. \singlespace %
  2464. % The following causes blank lines not to be ignored
  2465. % by adding a space to the end of each line.
  2466. \let\par=\lisppar
  2467. \def\Eformat{\endgroup\afterenvbreak}
  2468. \parskip=0pt \parindent=0pt
  2469. \obeyspaces \obeylines
  2470. \def\next##1{}\next}
  2471.  
  2472. % @flushleft and @flushright
  2473.  
  2474. \def\flushleft{%
  2475. \begingroup\inENV %This group ends at the end of the @format body
  2476. \aboveenvbreak
  2477. % Make spaces be word-separators rather than space tokens.
  2478. \sepspaces %
  2479. % The following causes blank lines not to be ignored
  2480. % by adding a space to the end of each line.
  2481. % This also causes @ to work when the directive name
  2482. % is terminated by end of line.
  2483. \let\par=\lisppar
  2484. \def\Eflushleft{\endgroup\afterenvbreak}%
  2485. \parskip=0pt \parindent=0pt
  2486. \obeyspaces \obeylines
  2487. \def\next##1{}\next}
  2488.  
  2489. \def\flushright{%
  2490. \begingroup\inENV %This group ends at the end of the @format body
  2491. \aboveenvbreak
  2492. % Make spaces be word-separators rather than space tokens.
  2493. \sepspaces %
  2494. % The following causes blank lines not to be ignored
  2495. % by adding a space to the end of each line.
  2496. % This also causes @ to work when the directive name
  2497. % is terminated by end of line.
  2498. \let\par=\lisppar
  2499. \def\Eflushright{\endgroup\afterenvbreak}%
  2500. \parskip=0pt \parindent=0pt
  2501. \advance \leftskip by 0pt plus 1fill
  2502. \obeyspaces \obeylines
  2503. \def\next##1{}\next}
  2504.  
  2505. % @quotation - narrow the margins.
  2506.  
  2507. \def\quotation{%
  2508. \begingroup\inENV %This group ends at the end of the @quotation body
  2509. {\parskip=0pt  % because we will skip by \parskip too, later
  2510. \aboveenvbreak}%
  2511. \singlespace
  2512. \parindent=0pt
  2513. \def\Equotation{\par\endgroup\afterenvbreak}%
  2514. % @cartouche defines \nonarrowing to inhibit narrowing
  2515. % at next level down.
  2516. \ifx\nonarrowing\relax
  2517. \advance \leftskip by \lispnarrowing
  2518. \advance \rightskip by \lispnarrowing
  2519. \exdentamount=\lispnarrowing
  2520. \let\nonarrowing=\relax
  2521. \fi}
  2522.  
  2523. \message{defuns,}
  2524. % Define formatter for defuns
  2525. % First, allow user to change definition object font (\df) internally
  2526. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2527.  
  2528. \newskip\defbodyindent \defbodyindent=.4in
  2529. \newskip\defargsindent \defargsindent=50pt
  2530. \newskip\deftypemargin \deftypemargin=12pt
  2531. \newskip\deflastargmargin \deflastargmargin=18pt
  2532.  
  2533. \newcount\parencount
  2534. % define \functionparens, which makes ( and ) and & do special things.
  2535. % \functionparens affects the group it is contained in.
  2536. \def\activeparens{%
  2537. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2538. \catcode`\[=\active \catcode`\]=\active}
  2539.  
  2540. % Make control sequences which act like normal parenthesis chars.
  2541. \let\lparen = ( \let\rparen = )
  2542.  
  2543. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2544.  
  2545. % Be sure that we always have a definition for `(', etc.  For example,
  2546. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2547. % so TeX would otherwise complain about undefined control sequence.
  2548. \global\let(=\lparen \global\let)=\rparen
  2549. \global\let[=\lbrack \global\let]=\rbrack
  2550.  
  2551. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2552. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2553.  
  2554. % Definitions of (, ) and & used in args for functions.
  2555. % This is the definition of ( outside of all parentheses.
  2556. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2557. \global\advance\parencount by 1 }
  2558. %
  2559. % This is the definition of ( when already inside a level of parens.
  2560. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2561. %
  2562. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2563. % also in that case restore the outer-level definition of (.
  2564. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2565. \global\advance \parencount by -1 }
  2566. % If we encounter &foo, then turn on ()-hacking afterwards
  2567. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2568. %
  2569. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2570. } % End of definition inside \activeparens
  2571. %% These parens (in \boldbrax) actually are a little bolder than the
  2572. %% contained text.  This is especially needed for [ and ]
  2573. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2574. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2575.  
  2576. % First, defname, which formats the header line itself.
  2577. % #1 should be the function name.
  2578. % #2 should be the type of definition, such as "Function".
  2579.  
  2580. \def\defname #1#2{%
  2581. % Get the values of \leftskip and \rightskip as they were
  2582. % outside the @def...
  2583. \dimen2=\leftskip
  2584. \advance\dimen2 by -\defbodyindent
  2585. \dimen3=\rightskip
  2586. \advance\dimen3 by -\defbodyindent
  2587. \noindent        %
  2588. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2589. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2590. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2591. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2592. % Now output arg 2 ("Function" or some such)
  2593. % ending at \deftypemargin from the right margin,
  2594. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2595. {% Adjust \hsize to exclude the ambient margins,
  2596. % so that \rightline will obey them.
  2597. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2598. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2599. % Make all lines underfull and no complaints:
  2600. \tolerance=10000 \hbadness=10000    
  2601. \advance\leftskip by -\defbodyindent
  2602. \exdentamount=\defbodyindent
  2603. {\df #1}\enskip        % Generate function name
  2604. }
  2605.  
  2606. % Actually process the body of a definition
  2607. % #1 should be the terminating control sequence, such as \Edefun.
  2608. % #2 should be the "another name" control sequence, such as \defunx.
  2609. % #3 should be the control sequence that actually processes the header,
  2610. %    such as \defunheader.
  2611.  
  2612. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2613. \medbreak %
  2614. % Define the end token that this defining construct specifies
  2615. % so that it will exit this group.
  2616. \def#1{\endgraf\endgroup\medbreak}%
  2617. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2618. \parindent=0in
  2619. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2620. \exdentamount=\defbodyindent
  2621. \begingroup %
  2622. \catcode 61=\active %
  2623. \obeylines\activeparens\spacesplit#3}
  2624.  
  2625. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2626. \medbreak %
  2627. % Define the end token that this defining construct specifies
  2628. % so that it will exit this group.
  2629. \def#1{\endgraf\endgroup\medbreak}%
  2630. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2631. \parindent=0in
  2632. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2633. \exdentamount=\defbodyindent
  2634. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2635.  
  2636. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2637. \medbreak %
  2638. % Define the end token that this defining construct specifies
  2639. % so that it will exit this group.
  2640. \def#1{\endgraf\endgroup\medbreak}%
  2641. \def#2##1 ##2 {\def#4{##1}%
  2642. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2643. \parindent=0in
  2644. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2645. \exdentamount=\defbodyindent
  2646. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2647.  
  2648. % These parsing functions are similar to the preceding ones
  2649. % except that they do not make parens into active characters.
  2650. % These are used for "variables" since they have no arguments.
  2651.  
  2652. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2653. \medbreak %
  2654. % Define the end token that this defining construct specifies
  2655. % so that it will exit this group.
  2656. \def#1{\endgraf\endgroup\medbreak}%
  2657. \def#2{\begingroup\obeylines\spacesplit#3}%
  2658. \parindent=0in
  2659. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2660. \exdentamount=\defbodyindent
  2661. \begingroup %
  2662. \catcode 61=\active %
  2663. \obeylines\spacesplit#3}
  2664.  
  2665. \def\defvrparsebody #1#2#3#4 {\begingroup\inENV %
  2666. \medbreak %
  2667. % Define the end token that this defining construct specifies
  2668. % so that it will exit this group.
  2669. \def#1{\endgraf\endgroup\medbreak}%
  2670. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2671. \parindent=0in
  2672. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2673. \exdentamount=\defbodyindent
  2674. \begingroup\obeylines\spacesplit{#3{#4}}}
  2675.  
  2676. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  2677. \medbreak %
  2678. % Define the end token that this defining construct specifies
  2679. % so that it will exit this group.
  2680. \def#1{\endgraf\endgroup\medbreak}%
  2681. \def#2##1 ##2 {\def#4{##1}%
  2682. \begingroup\obeylines\spacesplit{#3{##2}}}%
  2683. \parindent=0in
  2684. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2685. \exdentamount=\defbodyindent
  2686. \begingroup\obeylines\spacesplit{#3{#5}}}
  2687.  
  2688. % Split up #2 at the first space token.
  2689. % call #1 with two arguments:
  2690. %  the first is all of #2 before the space token,
  2691. %  the second is all of #2 after that space token.
  2692. % If #2 contains no space token, all of it is passed as the first arg
  2693. % and the second is passed as empty.
  2694.  
  2695. {\obeylines
  2696. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2697. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2698. \ifx\relax #3%
  2699. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2700.  
  2701. % So much for the things common to all kinds of definitions.
  2702.  
  2703. % Define @defun.
  2704.  
  2705. % First, define the processing that is wanted for arguments of \defun
  2706. % Use this to expand the args and terminate the paragraph they make up
  2707.  
  2708. \def\defunargs #1{\functionparens \sl
  2709. % Expand, preventing hyphenation at `-' chars.
  2710. % Note that groups don't affect changes in \hyphenchar.
  2711. \hyphenchar\tensl=0
  2712. #1%
  2713. \hyphenchar\tensl=45
  2714. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2715. \interlinepenalty=10000
  2716. \advance\rightskip by 0pt plus 1fil
  2717. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2718. }
  2719.  
  2720. \def\deftypefunargs #1{%
  2721. % Expand, preventing hyphenation at `-' chars.
  2722. % Note that groups don't affect changes in \hyphenchar.
  2723. \functionparens
  2724. \code{#1}%
  2725. \interlinepenalty=10000
  2726. \advance\rightskip by 0pt plus 1fil
  2727. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2728. }
  2729.  
  2730. % Do complete processing of one @defun or @defunx line already parsed.
  2731.  
  2732. % @deffn Command forward-char nchars
  2733.  
  2734. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2735.  
  2736. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2737. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2738. \catcode 61=\other % Turn off change made in \defparsebody
  2739. }
  2740.  
  2741. % @defun == @deffn Function
  2742.  
  2743. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2744.  
  2745. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2746. \begingroup\defname {#1}{Function}%
  2747. \defunargs {#2}\endgroup %
  2748. \catcode 61=\other % Turn off change made in \defparsebody
  2749. }
  2750.  
  2751. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2752.  
  2753. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2754.  
  2755. % #1 is the data type.  #2 is the name and args.
  2756. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2757. % #1 is the data type, #2 the name, #3 the args.
  2758. \def\deftypefunheaderx #1#2 #3\relax{%
  2759. \doind {fn}{\code{#2}}% Make entry in function index
  2760. \begingroup\defname {\code{#1} #2}{Function}%
  2761. \deftypefunargs {#3}\endgroup %
  2762. \catcode 61=\other % Turn off change made in \defparsebody
  2763. }
  2764.  
  2765. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2766.  
  2767. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2768.  
  2769. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2770. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2771. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2772. \def\deftypefnheaderx #1#2#3 #4\relax{%
  2773. \doind {fn}{\code{#3}}% Make entry in function index
  2774. \begingroup\defname {\code{#2} #3}{#1}%
  2775. \deftypefunargs {#4}\endgroup %
  2776. \catcode 61=\other % Turn off change made in \defparsebody
  2777. }
  2778.  
  2779. % @defmac == @deffn Macro
  2780.  
  2781. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2782.  
  2783. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2784. \begingroup\defname {#1}{Macro}%
  2785. \defunargs {#2}\endgroup %
  2786. \catcode 61=\other % Turn off change made in \defparsebody
  2787. }
  2788.  
  2789. % @defspec == @deffn Special Form
  2790.  
  2791. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2792.  
  2793. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2794. \begingroup\defname {#1}{Special Form}%
  2795. \defunargs {#2}\endgroup %
  2796. \catcode 61=\other % Turn off change made in \defparsebody
  2797. }
  2798.  
  2799. % This definition is run if you use @defunx
  2800. % anywhere other than immediately after a @defun or @defunx.
  2801.  
  2802. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2803. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2804. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2805. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2806. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2807. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2808.  
  2809. % @defmethod, and so on
  2810.  
  2811. % @defop {Funny Method} foo-class frobnicate argument
  2812.  
  2813. \def\defop #1 {\def\defoptype{#1}%
  2814. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2815.  
  2816. \def\defopheader #1#2#3{%
  2817. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2818. \begingroup\defname {#2}{\defoptype{} on #1}%
  2819. \defunargs {#3}\endgroup %
  2820. }
  2821.  
  2822. % @defmethod == @defop Method
  2823.  
  2824. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2825.  
  2826. \def\defmethodheader #1#2#3{%
  2827. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2828. \begingroup\defname {#2}{Method on #1}%
  2829. \defunargs {#3}\endgroup %
  2830. }
  2831.  
  2832. % @defcv {Class Option} foo-class foo-flag
  2833.  
  2834. \def\defcv #1 {\def\defcvtype{#1}%
  2835. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2836.  
  2837. \def\defcvarheader #1#2#3{%
  2838. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2839. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2840. \defvarargs {#3}\endgroup %
  2841. }
  2842.  
  2843. % @defivar == @defcv {Instance Variable}
  2844.  
  2845. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  2846.  
  2847. \def\defivarheader #1#2#3{%
  2848. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2849. \begingroup\defname {#2}{Instance Variable of #1}%
  2850. \defvarargs {#3}\endgroup %
  2851. }
  2852.  
  2853. % These definitions are run if you use @defmethodx, etc.,
  2854. % anywhere other than immediately after a @defmethod, etc.
  2855.  
  2856. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2857. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2858. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2859. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2860.  
  2861. % Now @defvar
  2862.  
  2863. % First, define the processing that is wanted for arguments of @defvar.
  2864. % This is actually simple: just print them in roman.
  2865. % This must expand the args and terminate the paragraph they make up
  2866. \def\defvarargs #1{\normalparens #1%
  2867. \interlinepenalty=10000
  2868. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2869.  
  2870. % @defvr Counter foo-count
  2871.  
  2872. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  2873.  
  2874. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2875. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2876.  
  2877. % @defvar == @defvr Variable
  2878.  
  2879. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  2880.  
  2881. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2882. \begingroup\defname {#1}{Variable}%
  2883. \defvarargs {#2}\endgroup %
  2884. }
  2885.  
  2886. % @defopt == @defvr {User Option}
  2887.  
  2888. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  2889.  
  2890. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2891. \begingroup\defname {#1}{User Option}%
  2892. \defvarargs {#2}\endgroup %
  2893. }
  2894.  
  2895. % @deftypevar int foobar
  2896.  
  2897. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2898.  
  2899. % #1 is the data type.  #2 is the name.
  2900. \def\deftypevarheader #1#2{%
  2901. \doind {vr}{\code{#2}}% Make entry in variables index
  2902. \begingroup\defname {\code{#1} #2}{Variable}%
  2903. \interlinepenalty=10000
  2904. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2905. \endgroup}
  2906.  
  2907. % @deftypevr {Global Flag} int enable
  2908.  
  2909. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2910.  
  2911. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2912. \begingroup\defname {\code{#2} #3}{#1}
  2913. \interlinepenalty=10000
  2914. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2915. \endgroup}
  2916.  
  2917. % This definition is run if you use @defvarx
  2918. % anywhere other than immediately after a @defvar or @defvarx.
  2919.  
  2920. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2921. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2922. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2923. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2924. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2925.  
  2926. % Now define @deftp
  2927. % Args are printed in bold, a slight difference from @defvar.
  2928.  
  2929. \def\deftpargs #1{\bf \defvarargs{#1}}
  2930.  
  2931. % @deftp Class window height width ...
  2932.  
  2933. \def\deftp{\defvrparsebody\Edeftp\deftpx\deftpheader}
  2934.  
  2935. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2936. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2937.  
  2938. % This definition is run if you use @deftpx, etc
  2939. % anywhere other than immediately after a @deftp, etc.
  2940.  
  2941. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2942.  
  2943. \message{cross reference,}
  2944. % Define cross-reference macros
  2945. \newwrite \auxfile
  2946.  
  2947. \newif\ifhavexrefs  % True if xref values are known.
  2948. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2949.  
  2950. % \setref{foo} defines a cross-reference point named foo.
  2951.  
  2952. \def\setref#1{%
  2953. %\dosetq{#1-title}{Ytitle}%
  2954. \dosetq{#1-pg}{Ypagenumber}%
  2955. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2956.  
  2957. \def\unnumbsetref#1{%
  2958. %\dosetq{#1-title}{Ytitle}%
  2959. \dosetq{#1-pg}{Ypagenumber}%
  2960. \dosetq{#1-snt}{Ynothing}}
  2961.  
  2962. \def\appendixsetref#1{%
  2963. %\dosetq{#1-title}{Ytitle}%
  2964. \dosetq{#1-pg}{Ypagenumber}%
  2965. \dosetq{#1-snt}{Yappendixletterandtype}}
  2966.  
  2967. % \xref, \pxref, and \ref generate cross-references to specified points.
  2968. % For \xrefX, #1 is the node name, #2 the name of the Info
  2969. % cross-reference, #3 the printed node name, #4 the name of the Info
  2970. % file, #5 the name of the printed manual.  All but the node name can be
  2971. % omitted.
  2972. \def\pxref#1{see \xrefX[#1,,,,,,,]}
  2973. \def\xref#1{See \xrefX[#1,,,,,,,]}
  2974. \def\ref#1{\xrefX[#1,,,,,,,]}
  2975. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
  2976. \def\printedmanual{\ignorespaces #5}%
  2977. \def\printednodename{\ignorespaces #3}%
  2978. %
  2979. \setbox1=\hbox{\printedmanual}%
  2980. \setbox0=\hbox{\printednodename}%
  2981. \ifdim \wd0=0pt%
  2982. \def\printednodename{\ignorespaces #1}%
  2983. %%% Uncommment the following line to make the actual chapter or section title
  2984. %%% appear inside the square brackets.
  2985. %\def\printednodename{#1-title}%
  2986. \fi%
  2987. %
  2988. %
  2989. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does
  2990. % not insert empty discretionaries after hyphens, which means that it
  2991. % will not find a line break at a hyphen in a node names.  Since some
  2992. % manuals are best written with fairly long node names, containing
  2993. % hyphens, this is a loss.  Therefore, we simply give the text of
  2994. % the node name again, so it is as if TeX is seeing it for the first
  2995. % time.
  2996. \ifdim \wd1>0pt
  2997. section ``\printednodename'' in \cite{\printedmanual}%
  2998. \else%
  2999. \turnoffactive%
  3000. \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}%
  3001. \fi
  3002. \endgroup}
  3003.  
  3004. % \dosetq is the interface for calls from other macros
  3005.  
  3006. % Use \turnoffactive so that punctuation chars such as underscore
  3007. % work in node names.
  3008. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  3009. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  3010. \next}}
  3011.  
  3012. % \internalsetq {foo}{page} expands into
  3013. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  3014. % When the aux file is read, ' is the escape character
  3015.  
  3016. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  3017.  
  3018. % Things to be expanded by \internalsetq
  3019.  
  3020. \def\Ypagenumber{\folio}
  3021.  
  3022. \def\Ytitle{\thischapter}
  3023.  
  3024. \def\Ynothing{}
  3025.  
  3026. \def\Ysectionnumberandtype{%
  3027. \ifnum\secno=0 Chapter\xreftie\the\chapno %
  3028. \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno %
  3029. \else \ifnum \subsubsecno=0 %
  3030. Section\xreftie\the\chapno.\the\secno.\the\subsecno %
  3031. \else %
  3032. Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  3033. \fi \fi \fi }
  3034.  
  3035. \def\Yappendixletterandtype{%
  3036. \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}%
  3037. \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno %
  3038. \else \ifnum \subsubsecno=0 %
  3039. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  3040. \else %
  3041. Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  3042. \fi \fi \fi }
  3043.  
  3044. \gdef\xreftie{'tie}
  3045.  
  3046. % Use TeX 3.0's \inputlineno to get the line number, for better error
  3047. % messages, but if we're using an old version of TeX, don't do anything.
  3048. \ifx\inputlineno\thisisundefined
  3049.   \let\linenumber = \empty % Non-3.0.
  3050. \else
  3051.   \def\linenumber{\the\inputlineno:\space}
  3052. \fi
  3053.  
  3054. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  3055. % If its value is nonempty, SUFFIX is output afterward.
  3056.  
  3057. \def\refx#1#2{%
  3058.   \expandafter\ifx\csname X#1\endcsname\relax
  3059.     % If not defined, say something at least.
  3060.     $\langle$un\-de\-fined$\rangle$%
  3061.     \ifhavexrefs
  3062.       \message{\linenumber Undefined cross reference `#1'.}%
  3063.     \else
  3064.       \ifwarnedxrefs\else
  3065.         \global\warnedxrefstrue
  3066.         \message{Cross reference values unknown; you must run TeX again.}%
  3067.       \fi
  3068.     \fi
  3069.   \else
  3070.     % It's defined, so just use it.
  3071.     \csname X#1\endcsname
  3072.   \fi
  3073.   #2% Output the suffix in any case.
  3074. }
  3075.  
  3076. % Read the last existing aux file, if any.  No error if none exists.
  3077.  
  3078. % This is the macro invoked by entries in the aux file.
  3079. \def\xrdef #1#2{
  3080. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  3081.  
  3082. \def\readauxfile{%
  3083. \begingroup
  3084. \catcode `\^^@=\other
  3085. \catcode `\⇧=\other
  3086. \catcode `\⇩=\other
  3087. \catcode `\^^C=\other
  3088. \catcode `\^^D=\other
  3089. \catcode `\^^E=\other
  3090. \catcode `\^^F=\other
  3091. \catcode `\^^G=\other
  3092. \catcode `\^^H=\other
  3093. \catcode `\♪=\other
  3094. \catcode `\^^L=\other
  3095. \catcode `\=\other
  3096. \catcode `\=\other
  3097. \catcode `\⓪=\other
  3098. \catcode `\①=\other
  3099. \catcode `\②=\other
  3100. \catcode `\③=\other
  3101. \catcode `\④=\other
  3102. \catcode `\⑤=\other
  3103. \catcode `\⑥=\other
  3104. \catcode `\⑦=\other
  3105. \catcode `\⑧=\other
  3106. \catcode `\⑨=\other
  3107. \catcode 26=\other
  3108. \catcode `\^^[=\other
  3109. \catcode `\^^\=\other
  3110. \catcode `\^^]=\other
  3111. \catcode `\^^^=\other
  3112. \catcode `\^^_=\other
  3113. \catcode `\@=\other
  3114. \catcode `\^=\other
  3115. \catcode `\~=\other
  3116. \catcode `\[=\other
  3117. \catcode `\]=\other
  3118. \catcode`\"=\other
  3119. \catcode`\_=\other
  3120. \catcode`\|=\other
  3121. \catcode`\<=\other
  3122. \catcode`\>=\other
  3123. \catcode `\$=\other
  3124. \catcode `\#=\other
  3125. \catcode `\&=\other
  3126. % the aux file uses ' as the escape.
  3127. % Turn off \ as an escape so we do not lose on
  3128. % entries which were dumped with control sequences in their names.
  3129. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  3130. % Reference to such entries still does not work the way one would wish,
  3131. % but at least they do not bomb out when the aux file is read in.
  3132. \catcode `\{=1 \catcode `\}=2
  3133. \catcode `\%=\other
  3134. \catcode `\'=0
  3135. \catcode `\\=\other
  3136. \openin 1 \jobname.aux
  3137. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  3138. \fi
  3139. % Open the new aux file.  Tex will close it automatically at exit.
  3140. \openout \auxfile=\jobname.aux
  3141. \endgroup}
  3142.  
  3143.  
  3144. % Footnotes.
  3145.  
  3146. \newcount \footnoteno
  3147.  
  3148. % The trailing space in the following definition for supereject is
  3149. % vital for proper filling; pages come out unaligned when you do a
  3150. % pagealignmacro call if that space before the closing brace is
  3151. % removed.
  3152. \def\supereject{\par\penalty -20000\footnoteno =0 }
  3153.  
  3154. % @footnotestyle is meaningful for info output only..
  3155. \let\footnotestyle=\comment
  3156.  
  3157. \let\ptexfootnote=\footnote
  3158.  
  3159. {\catcode `\@=11
  3160. \long\gdef\footnote #1{\global\advance \footnoteno by \@ne
  3161. \unskip
  3162. \edef\thisfootno{$^{\the\footnoteno}$}%
  3163. \let\@sf\empty
  3164. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  3165. \thisfootno\@sf \footnotezzz{#1}}
  3166. % \parsearg\footnotezzz}
  3167.  
  3168. \long\gdef\footnotezzz #1{\insert\footins{
  3169. \interlinepenalty\interfootnotelinepenalty
  3170. \splittopskip\ht\strutbox % top baseline for broken footnotes
  3171. \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  3172. \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
  3173. \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}}
  3174.  
  3175. }%end \catcode `\@=11
  3176.  
  3177. % End of control word definitions.
  3178.  
  3179. \message{and turning on texinfo input format.}
  3180.  
  3181. \def\openindices{%
  3182.    \newindex{cp}%
  3183.    \newcodeindex{fn}%
  3184.    \newcodeindex{vr}%
  3185.    \newcodeindex{tp}%
  3186.    \newcodeindex{ky}%
  3187.    \newcodeindex{pg}%
  3188. }
  3189.  
  3190. % Set some numeric style parameters, for 8.5 x 11 format.
  3191.  
  3192. %\hsize = 6.5in
  3193. \newdimen\defaultparindent \defaultparindent = 15pt
  3194. \parindent = \defaultparindent
  3195. \parskip 18pt plus 1pt
  3196. \baselineskip 15pt
  3197. \advance\topskip by 1.2cm
  3198.  
  3199. % Prevent underfull vbox error messages.
  3200. \vbadness=10000
  3201.  
  3202. % Following George Bush, just get rid of widows and orphans.
  3203. \widowpenalty=10000
  3204. \clubpenalty=10000
  3205.  
  3206. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  3207. % using an old version of TeX, don't do anything.  We want the amount of
  3208. % stretch added to depend on the line length, hence the dependence on
  3209. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  3210. \ifx\emergencystretch\thisisundefined \else
  3211.   \emergencystretch = \hsize
  3212.   \divide\emergencystretch by 45
  3213. \fi
  3214.  
  3215. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  3216. \def\smallbook{
  3217. \global\lispnarrowing = 0.3in
  3218. \global\baselineskip 12pt
  3219. \advance\topskip by -1cm
  3220. \global\parskip 3pt plus 1pt
  3221. \global\hsize = 5in
  3222. \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in
  3223. \global\vsize=7.5in
  3224. \global\tolerance=700
  3225. \global\hfuzz=1pt
  3226. \global\contentsrightmargin=0pt
  3227.  
  3228. \global\pagewidth=\hsize
  3229. \global\pageheight=\vsize
  3230.  
  3231. \global\let\smalllisp=\smalllispx
  3232. \global\let\smallexample=\smalllispx
  3233. \global\def\Esmallexample{\Esmalllisp}
  3234. }
  3235.  
  3236. % Use @afourpaper to print on European A4 paper.
  3237. \def\afourpaper{
  3238. \global\tolerance=700
  3239. \global\hfuzz=1pt
  3240. \global\baselineskip=12pt
  3241. \global\parskip 15pt plus 1pt
  3242.  
  3243. \global\vsize= 53\baselineskip
  3244. \advance\vsize by \topskip
  3245. %\global\hsize=   5.85in     % A4 wide 10pt
  3246. \global\hsize=  6.5in
  3247. \global\outerhsize=\hsize
  3248. \global\advance\outerhsize by 0.5in
  3249. \global\outervsize=\vsize
  3250. \global\advance\outervsize by 0.6in
  3251. \global\doublecolumnhsize=\hsize
  3252. \global\divide\doublecolumnhsize by 2
  3253. \global\advance\doublecolumnhsize by -0.1in
  3254. \global\doublecolumnvsize=\vsize
  3255. \global\multiply\doublecolumnvsize by 2
  3256. \global\advance\doublecolumnvsize by 0.1in
  3257.  
  3258. \global\pagewidth=\hsize
  3259. \global\pageheight=\vsize
  3260. }
  3261.  
  3262. %% For a final copy, take out the rectangles
  3263. %% that mark overfull boxes (in case you have decided
  3264. %% that the text looks ok even though it passes the margin).
  3265. \def\finalout{\overfullrule=0pt}
  3266.  
  3267. % Define macros to output various characters with catcode for normal text.
  3268. \catcode`\"=\other
  3269. \catcode`\~=\other
  3270. \catcode`\^=\other
  3271. \catcode`\_=\other
  3272. \catcode`\|=\other
  3273. \catcode`\<=\other
  3274. \catcode`\>=\other
  3275. \catcode`\+=\other
  3276. \def\normaldoublequote{"}
  3277. \def\normaltilde{~}
  3278. \def\normalcaret{^}
  3279. \def\normalunderscore{_}
  3280. \def\normalverticalbar{|}
  3281. \def\normalless{<}
  3282. \def\normalgreater{>}
  3283. \def\normalplus{+}
  3284.  
  3285. % This macro is used to make a character print one way in ttfont
  3286. % where it can probably just be output, and another way in other fonts,
  3287. % where something hairier probably needs to be done.
  3288. %
  3289. % #1 is what to print if we are indeed using \tt; #2 is what to print
  3290. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  3291. % interword stretch (and shrink), and it is reasonable to expect all
  3292. % typewriter fonts to have this, we can check that font parameter.
  3293. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  3294.  
  3295. % Turn off all special characters except @
  3296. % (and those which the user can use as if they were ordinary).
  3297. % Most of these we simply print from the \tt font, but for some, we can
  3298. % use math or other variants that look better in normal text.
  3299.  
  3300. \catcode`\"=\active
  3301. \def\activedoublequote{{\tt \char '042}}
  3302. \let"=\activedoublequote
  3303. \catcode`\~=\active
  3304. \def~{{\tt \char '176}}
  3305. \chardef\hat=`\^
  3306. \catcode`\^=\active
  3307. \def^{{\tt \hat}}
  3308.  
  3309. \catcode`\_=\active
  3310. \def_{\ifusingtt\normalunderscore\_}
  3311. % Subroutine for the previous macro.
  3312. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  3313.  
  3314. % \lvvmode is equivalent in function to \leavevmode.
  3315. % Using \leavevmode runs into trouble when written out to
  3316. % an index file due to the expansion of \leavevmode into ``\unhbox
  3317. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  3318. % magic tricks with @.
  3319. \def\lvvmode{\vbox to 0pt{}}
  3320.  
  3321. \catcode`\|=\active
  3322. \def|{{\tt \char '174}}
  3323. \chardef \less=`\<
  3324. \catcode`\<=\active
  3325. \def<{{\tt \less}}
  3326. \chardef \gtr=`\>
  3327. \catcode`\>=\active
  3328. \def>{{\tt \gtr}}
  3329. \catcode`\+=\active
  3330. \def+{{\tt \char 43}}
  3331. %\catcode 27=\active
  3332. %\def^^[{$\diamondsuit$}
  3333.  
  3334. % Used sometimes to turn off (effectively) the active characters
  3335. % even after parsing them.
  3336. \def\turnoffactive{\let"=\normaldoublequote
  3337. \let~=\normaltilde
  3338. \let^=\normalcaret
  3339. \let_=\normalunderscore
  3340. \let|=\normalverticalbar
  3341. \let<=\normalless
  3342. \let>=\normalgreater
  3343. \let+=\normalplus}
  3344.  
  3345. % Set up an active definition for =, but don't enable it most of the time.
  3346. {\catcode`\==\active
  3347. \global\def={{\tt \char 61}}}
  3348.  
  3349. \catcode`\@=0
  3350.  
  3351. % \rawbackslashxx output one backslash character in current font
  3352. \global\chardef\rawbackslashxx=`\\
  3353. %{\catcode`\\=\other
  3354. %@gdef@rawbackslashxx{\}}
  3355.  
  3356. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  3357. {\catcode`\\=\active
  3358. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  3359.  
  3360. % \normalbackslash outputs one backslash in fixed width font.
  3361. \def\normalbackslash{{\tt\rawbackslashxx}}
  3362.  
  3363. % Say @foo, not \foo, in error messages.
  3364. \escapechar=`\@
  3365.  
  3366. % \catcode 17=0   % Define control-q
  3367. \catcode`\\=\active
  3368.  
  3369. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  3370. % That is what \eatinput is for; after that, the `\' should revert to printing 
  3371. % a backslash.
  3372. %
  3373. @gdef@eatinput input texinfo{@fixbackslash}
  3374. @global@let\ = @eatinput
  3375.  
  3376. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  3377. % the first `\{ in the file would cause an error. This macro tries to fix 
  3378. % that, assuming it is called before the first `\' could plausibly occur.
  3379. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  3380.  
  3381. %% These look ok in all fonts, so just make them not special.  The @rm below
  3382. %% makes sure that the current font starts out as the newly loaded cmr10
  3383. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  3384.  
  3385. @textfonts
  3386. @rm
  3387.  
  3388. @c Local variables:
  3389. @c page-delimiter: "^\\\\message"
  3390. @c End:
  3391.